CSS:1/8长度的圆弧

标签 css border geometry

仅通过使用 CSS,我尝试创建具有一定宽度和颜色的圆弧,其长度是圆长度的 1/8 甚至更小(正如我想要的那样)达到整个圆各段之间有间隙的效果,见图。

enter image description here

我尝试了边框半径和边框样式的组合,但这只得到了 1/4。

参见 fiddle : http://jsfiddle.net/uc8wvtfb/

如何仅使用 CSS 来实现这一点?

HTML:

<div class="arc"></div>

CSS:

width: 50px;
height: 50px;
border-radius: 50%;
border-color: transparent transparent red transparent;
border-style: solid;
border-width: 0px 10px 10px 10px;

最佳答案

这是一种方法:Fiddle 。它是一个虚线边框叠加在另一个虚线边框之上。然后,您可以通过调整 transform:rotate(30deg) 值来调整虚线之间“间隙”的大小。

CSS

.arc {
    margin: 0 auto;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 15px dashed red;
    position: relative;
}

.arc:after {
    content: '';
    width: 200px;
    height: 200px;
    border-radius: 50%;
    position: absolute;
    top: -15px;
    left: -15px;
    border: 15px dashed red;
    -webkit-transform: rotate(30deg);
    transform: rotate(30deg);
}

关于CSS:1/8长度的圆弧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25253233/

相关文章:

html - 向 Bootstrap Carousel 添加顶层

不遵守 CSS 字体大小

javascript - 日/夜模式 - CSS + JQuery - Cookies?

jquery - 如何在旋转木马中垂直居中随机高度的图像

java - 带 mouseEvent 处理的 JPanel 边框

jquery - 在jQuery中如何确定一个或多个div元素是否重叠并完全覆盖另一个div?

html - 圆形边框的问题

html - css 字段集边框

c++ - 使用 OpenGL 风扇而不是根据不同的位置创建圆有什么好处?

html - 使用 css 动画更改悬停时的圆圈背景