圆环5种方法。

Posted zhangyufeng0126

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了圆环5种方法。相关的知识,希望对你有一定的参考价值。

圆环5种方法。

1. 两个标签的嵌套:

 
  1. <div class="element1">

  2.     <div class="child1"></div>

  3. </div>

 
  1. .element1

  2. width: 200px;

  3. height: 200px;

  4. background-color: lightpink;

  5. border-radius: 50%;

  6. .child1

  7. width: 100px;

  8. height: 100px;

  9. border-radius: 50%;

  10. background-color: #009966;

  11. position: relative;

  12. top: 50px;

  13. left: 50px;

2. 使用伪元素,before/after

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

  2. width: 200px;

  3. height: 200px;

  4. background-color: lightpink;

  5. border-radius: 50%;

  6. .element2:after

  7. content: "";

  8. display: block;

  9. width: 100px;

  10. height: 100px;

  11. border-radius: 50%;

  12. background-color: #009966;

  13. position: relative;

  14. top: 50px;

  15. left: 50px;

3. 使用border:

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

  2. width: 100px;

  3. height: 100px;

  4. background-color: #009966;

  5. border-radius: 50%;

  6. border: 50px solid lightpink ;

4. 使用border-shadow

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

  2. width: 100px;

  3. height: 100px;

  4. background-color: #009966;

  5. border-radius: 50%;

  6. box-shadow: 0 0 0 50px lightpink ;

  7. margin: auto;

<div class="element5">
 
  1. .element5

  2. width: 200px;

  3. height: 200px;

  4. background-color: #009966;

  5. border-radius: 50%;

  6. box-shadow: 0 0 0 50px lightpink inset;

  7. margin: auto;

 

5. 使用radial-gradient

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

  2. width: 200px;

  3. height: 200px;

  4. border-radius: 50%;

  5. background: -webkit-radial-gradient( circle closest-side,#009966 50%,lightpink 50%);

 

以上是关于圆环5种方法。的主要内容,如果未能解决你的问题,请参考以下文章

结合面积和边缘亮度过度来提高圆环检测精度

iOS 绘制颜色渐变圆环

两种CSS3圆环进度条详解

UVa 818 切断圆环链(dfs+二进制枚举)

自定义控件:绘制圆环的实现过程

始终在 Angular 5 中显示圆环图工具提示