如何使用 stroke-dasharray 模式
假设您在 SVG 中有一条线
<svg<line x1="0" y1="30" x2="500" y2="30" stroke-color="#f8a100" /</svg
您可以使用 CSS 中的 stroke-dasharray
属性创建虚线
line {
stroke-dasharray: 5;
}
该 5
值是基于…的相对单位
假设您在 SVG 中有一条线
<svg<line x1="0" y1="30" x2="500" y2="30" stroke-color="#f8a100" /</svg
您可以使用 CSS 中的 stroke-dasharray
属性创建虚线
line {
stroke-dasharray: 5;
}
该 5
值是基于…的相对单位
在使用 SVG 绘制线条时,通常会有一个带有<path></path>
元素的stroke
。您设置一个与路径本身一样长的stroke-dasharray
,以及一个扩展到整个描边…的stroke-offset
。
CSS 中的stroke-dasharray
属性设置 SVG 形状描边中虚线的长度。更具体地说,它设置了交替的虚线和它们之间间隙的模式的长度…