stroke-dashoffset
Атрибут stroke-dashoffset — атрибут отображения, определяющий смещение при отрисовке связанного массива пунктира.
Примечание: В качестве атрибута отображения stroke-dashoffset можно использовать в качестве свойства CSS.
Вы можете использовать этот атрибут с следующими элементами SVG:
Пример
html
<svg viewBox="-3 0 33 10" xmlns="http://www.w3.org/2000/svg"> <!-- No dash array --> <line x1="0" y1="1" x2="30" y2="1" stroke="black" /> <!-- No dash offset --> <line x1="0" y1="3" x2="30" y2="3" stroke="black" stroke-dasharray="3 1" /> <!-- The start of the dash array computation is pulled by 3 user units --> <line x1="0" y1="5" x2="30" y2="5" stroke="black" stroke-dasharray="3 1" stroke-dashoffset="3" /> <!-- The start of the dash array computation is pushed by 3 user units --> <line x1="0" y1="7" x2="30" y2="7" stroke="black" stroke-dasharray="3 1" stroke-dashoffset="-3" /> <!-- The start of the dash array computation is pulled by 1 user units which ends up in the same rendering as the previous example --> <line x1="0" y1="9" x2="30" y2="9" stroke="black" stroke-dasharray="3 1" stroke-dashoffset="1" /> <!-- the following red lines highlight the offset of the dash array for each line --> <path d="M0,5 h-3 M0,7 h3 M0,9 h-1" stroke="rgb(255 0 0 / 50%)" /> </svg>
Примечания по использованию
Смещение обычно выражается в пользовательских единицах, определяемых относительно pathLength, но если используется <процент>, значение интерпретируется как процент от текущего области просмотра.
Спецификации
Совместимость с браузерами
| Рабочий стол | Мобильные устройства | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox для Android | Opera Android | Safari на iOS | Samsung Internet | WebView Android | |
stroke-dashoffset |
≤80 | ≤80 | ≤72 | 67 | ≤13.1 | 80 | 79 | 57 | ≤13.4 | 13.0 | 80 |
© 2005–2024 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dashoffset