166  
查询码:00000794
实现CSS圆环的5种方法
来源:https://www.jb51.net/css/635265.html
作者: 朱凡 于 2021年01月16日 发布在分类 / FM组 / FM_App 下,并于 2021年01月16日 编辑
圆环 border element 实现 background height radius 大家 border-radius 教程

实现CSS圆环的5种方法(小结)

1. 两个标签的嵌套:


<div class="element1">
  <div class="child1"></div>
</div>



.element1{
      width: 200px;
      height: 200px;
      background-color: lightpink;
      border-radius: 50%;
    }
    .child1{
      width: 100px;
      height: 100px;
      border-radius: 50%;
      background-color: #009966;
      position: relative;
      top: 50px;
      left: 50px;
    }


2. 使用伪元素,before/after


<div class="element2"></div>



.element2{
      width: 200px;
      height: 200px;
      background-color: lightpink;
      border-radius: 50%;
    }
    .element2:after{
      content: "";
      display: block;
      width: 100px;
      height: 100px;
      border-radius: 50%;
      background-color: #009966;
      position: relative;
      top: 50px;
      left: 50px;
    }


3. 使用border:


<div class="element3"></div>



 .element3{
      width: 100px;
      height: 100px;
      background-color: #009966;
      border-radius: 50%;
      border: 50px solid lightpink ;
    }


4. 使用border-shadow


<div class="element4"></div>



.element4{
      width: 100px;
      height: 100px;
      background-color: #009966;
      border-radius: 50%;
      box-shadow: 0 0 0 50px lightpink ;
      margin: auto;
    }



<div class="element5">



 .element5{
      width: 200px;
      height: 200px;
      background-color: #009966;
      border-radius: 50%;
      box-shadow: 0 0 0 50px lightpink inset;
      margin: auto;
    }


5. 使用radial-gradient


<div class="element6"></div>



.element6{
      width: 200px;
      height: 200px;
      border-radius: 50%;
      background: -webkit-radial-gradient( circle closest-side,#009966 50%,lightpink 50%);
    }


 推荐知识

 历史版本

修改日期 修改人 备注
2021-01-16 14:45:40[当前版本] 朱凡 创建版本

 附件

附件类型

JPGJPG

知识分享平台 -V 4.8.7 -wcp