Ilj*_*lja 16 html css html5 css3 css-shapes
我正在尝试使用纯css实现以下外观:

每个白弧是一个不同的元素,比如跨度.我知道我们可以用css制作圆形,但它又怎么能变成弧形呢?
Dav*_*mas 59
使用以下HTML:
<div id="arcs">
<div>
<div>
<div>
<div></div>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
而CSS:
#arcs div {
border: 2px solid #000; /* the 'strokes' of the arc */
display: inline-block;
min-width: 4em; /* the width of the innermost element */
min-height: 4em; /* the height of the innermost element */
padding: 0.5em; /* the spacing between each arc */
border-radius: 50%; /* for making the elements 'round' */
border-top-color: transparent; /* hiding the top border */
border-bottom-color: transparent;
}
Run Code Online (Sandbox Code Playgroud)
#arcs div {
border: 2px solid #000;
/* the 'strokes' of the arc */
display: inline-block;
min-width: 4em;
/* the width of the innermost element */
min-height: 4em;
/* the height of the innermost element */
padding: 0.5em;
/* the spacing between each arc */
border-radius: 50%;
/* for making the elements 'round' */
border-top-color: transparent;
/* hiding the top border */
border-bottom-color: transparent;
}Run Code Online (Sandbox Code Playgroud)
<div id="arcs">
<div>
<div>
<div>
<div></div>
</div>
</div>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
我建议你使用SVG绘制这样的形状:
在下面的例子中,我使用SVG的path元素绘制弧.该元素采用单个属性d来描述形状结构.d属性采用一些命令和相应的必要参数.
我只使用了2个路径命令:
M命令用于将笔移动到特定点.此命令需要2个参数x,y通常我们的路径以此命令开头.它基本上定义了我们绘图的起点.A用于绘制曲线和圆弧的命令.此命令需要7个参数来绘制圆弧/曲线.此命令的详细说明如下.截图:
有用的资源:
工作实例:
svg {
width: 33%;
height: auto;
}Run Code Online (Sandbox Code Playgroud)
<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg">
<defs>
<g id="arcs" fill="none" stroke="#fcfcfc">
<path d="M80,80 A100,100,0, 0,0 80,220" stroke-width="4" />
<path d="M90,90 A85,85,0, 0,0 90,210" stroke-width="3.5" />
<path d="M100,100 A70,70,0, 0,0 100,200" stroke-width="3" />
<path d="M110,110 A55,55,0, 0,0 110,190" stroke-width="2.5" />
</g>
</defs>
<rect x="0" y="0" width="300" height="300" fill="#373737" />
<use xlink:href="#arcs" />
<use xlink:href="#arcs" transform="translate(300,300) rotate(180)" />
</svg>Run Code Online (Sandbox Code Playgroud)