请老师检查,渐变的实现效果麻烦老师优化

请老师检查,渐变的实现效果麻烦老师优化

方式一:<!DOCTYPE html>

<html>


<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>rainbow</title>

    <style>

        .box {

            width: 500px;

            height: 200px;

            overflow: hidden;

            position: relative;

            padding: 20px;

        }


        .purple,

        .blue,

        .green,

        .yellow,

        .red {

            border-radius: 50%;

            position: absolute;

            margin: 0 auto;

        }


        .purple {

            width: 480px;

            height: 480px;

            border: 20px solid purple;

        }


        .blue {

            width: 440px;

            height: 440px;

            border: 20px solid blue;

            margin-top: 20px;

            margin-left: 20px;

        }


        .green {

            width: 400px;

            height: 400px;

            border: 20px solid green;

            margin-top: 40px;

            margin-left: 40px;

        }


        .yellow {

            width: 360px;

            height: 360px;

            border: 20px solid yellow;

            margin-top: 60px;

            margin-left: 60px;

        }


        .red {

            width: 320px;

            height: 320px;

            border: 20px solid red;

            margin-top: 80px;

            margin-left: 80px;

        }

    </style>

</head>


<body>

    <div class="box">

        <div class="purple"></div>

        <div class="blue"></div>

        <div class="green"></div>

        <div class="yellow"></div>

        <div class="red"></div>

    </div>

</body>


</html>


方式二:

<!DOCTYPE html>

<html>


<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>rainbow</title>

    <style>

        .box2 {

            width: 500px;

            height: 200px;

            overflow: hidden;

            position: relative;

            padding: 20px;

        }


        .example3 {

            position: absolute;

            width: 500px;

            height: 500px;

            border-radius: 50%;

            background-image: -webkit-gradient(radial, center center, 0, center center, 220, color-stop(0.20, transparent), color-stop(0.40, red), color-stop(0.6, green), color-stop(0.8, blue), color-stop(1, purple));



        }

    </style>

</head>


<body>

    <div class="box2">

        <div class="example3">

        </div>

    </div>

</body>

</html>


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
好帮手慕然然 2021-09-01 15:26:16

同学你好,再补充一点,关于方式二中使用渐变实现的“彩虹”效果可以优化一下,如图

https://img1.sycdn.imooc.com//climg/612f2b09098d15ae17170458.jpg

祝学习愉快!

好帮手慕然然 2021-09-01 15:00:33

同学你好,方式一实现效果很棒,不需要优化。方式二的彩虹效果中缺少了黄色的彩虹,建议添加上,参考如下

https://img1.sycdn.imooc.com//climg/612f250a09e69ae516230495.jpg

祝学习愉快!

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师