如何在里面切割创建透明圆圈?

时间:2016-03-03 18:34:45

标签: html css html5 css3

我们可以创建带有css和html内部切割的透明圆圈吗? 我附上了图片以便澄清

transparent circle with cut inside



.circle {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 1px solid black;
}

<div class="circle"></div>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:3)

您可以使用:after伪元素

执行此操作

&#13;
&#13;
.circle {
  width: 150px;
  height: 150px;
  border-top: 2px solid black;
  border-left: 2px solid black;
  border-right: 2px solid black;
  border-bottom: 2px solid transparent;
  border-radius: 50%;
  position: relative;
  transform: rotate(30deg);
}

.circle:after {
  content: '';
  position: absolute;
  bottom: 0;
  border-radius: 50%;
  height: 10px;
  width: 40px;
  left: 50%;
  transform: translate(-50%, 7%);
  border-bottom: 2px solid black;
  border-top: 2px solid transparent;
  border-left: 2px solid transparent;
  border-right: 2px solid transparent;
}
&#13;
<div class="circle"></div>
&#13;
&#13;
&#13;

答案 1 :(得分:2)

SVG可能是一种选择。

看到这个优秀的Answer

More complex Codepen Demo

&#13;
&#13;
svg {
  height: 100px;
  width: 100px;
}
circle {
  fill: transparent;
  stroke: green;
  stroke-width: 3;
}
.dashed {
  stroke-dasharray: 75, 10;
}
div {
  height: 100px;
  width: 100px;
  color: green;
  font-weight: bold;
  text-align: center;
  line-height: 100px;
}
&#13;
<svg viewBox="0 0 120 120">
  <circle cx="55" cy="55" r="50" class="dashed" />
</svg>
&#13;
&#13;
&#13;