前端知識總結--css用div畫環形圓


如何用最少的div畫最多的環形?如下圖所示最少需要多少個div?

暫時想到的利用div的邊框、內外陰影及befor和after的偽元素實現

以下代碼可以實現上圖效果:

<style>
    div{
        height: 100px;
        width: 100px;
        border-radius: 100px;
        position: absolute;
        top: 40%;
        left: 40%;
        border: solid 10px purple;
        box-shadow: 0px 0px 0px 10px red,0px 0px 0px 10px black inset;
        background: gray;

    }
    div::after{
        content:' ';
        background-color: yellow; 
        border-radius: 100px;
        display: block;
        z-index: -1;
        position: relative; 
        left: -30px;
        top: -30px;
        width: 160px;
        height: 160px;
    }
    div::before{
        content:' ';
        background-color: green; 
        border-radius: 100px;
        display: block;
        z-index: -2;
        position: absolute; 
        left: -40px;
        top: -40px; 
        width: 180px;
        height: 180px;
    }
    </style>

<div></div>

 

 歡迎批評指正!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM