CSS |笔画偏移属性
原文:https://www . geesforgeks . org/CSS-stroke-dash offset-property/
笔划-dashoffset 属性用于设置沿 SVG 路径的位置,笔划的虚线图案将从该位置开始。较高的值意味着破折号将从更远的位置开始。
语法:
stroke-dasharray: <length> | <percentage>
属性值:
-
length: It is used to set the offset in length units. The values are resolved on the basis of the path length of the element.
示例 1: 设置线中虚线的偏移量。
```html <!DOCTYPE html>
CSS | stroke-dashoffset .stroke1 { stroke-dashoffset: 0;stroke: green; stroke-dasharray: 40; stroke-width: 20px; }
.stroke2 { stroke-dashoffset: 15px;
stroke: red; stroke-dasharray: 40; stroke-width: 20px; }
.stroke3 { stroke-dashoffset: 30px;
stroke: orange; stroke-dasharray: 40; stroke-width: 20px; }
GeeksforGeeks
CSS | stroke-dashoffset输出:
示例 2: 设置圆圈中虚线的偏移量。
```html <!DOCTYPE html>
CSS | stroke-dashoffset .stroke1 { stroke-dashoffset: 0;stroke: green; stroke-dasharray: 40; stroke-width: 10px; }
.stroke2 { stroke-dashoffset: 15px;
stroke: red; stroke-dasharray: 40; stroke-width: 10px; }
.stroke3 { stroke-dashoffset: 30px;
stroke: orange; stroke-dasharray: 40; stroke-width: 10px; }
GeeksforGeeks
CSS | stroke-dashoffset输出:
-
percentage: It is used to set the offset in percentage values. The values are resolved as a percentage of the current viewport.
示例:设置线中虚线的偏移量。
```html <!DOCTYPE html>
CSS | stroke-dashoffset .stroke1 { stroke-dashoffset: 0%;stroke: green; stroke-dasharray: 40; stroke-width: 20px; }
.stroke2 { stroke-dashoffset: 50%;
stroke: red; stroke-dasharray: 40; stroke-width: 20px; }
.stroke3 { stroke-dashoffset: 100%;
stroke: orange; stroke-dasharray: 40; stroke-width: 20px; }
GeeksforGeeks
CSS | stroke-dashoffset输出:
支持的浏览器:笔画偏移属性支持的浏览器如下:
- 铬
- 火狐浏览器
- 旅行队
- 歌剧
- Internet Explorer 9
版权属于:月萌API www.moonapi.com,转载请注明出处