Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zh-cn: update the translation of the SVG attribute stroke-dashoffset #23063

Merged
merged 10 commits into from
Aug 15, 2024
89 changes: 80 additions & 9 deletions files/zh-cn/web/svg/attribute/stroke-dashoffset/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,100 @@ slug: Web/SVG/Attribute/stroke-dashoffset

{{SVGRef}}

`stroke-dashoffset` 属性指定了 dash 模式到路径开始的距离
`stroke-dashoffset` 属性定义了虚线与路径起点的偏移量。
Gahotx marked this conversation as resolved.
Show resolved Hide resolved

如果使用了一个 [<百分比>](/zh-CN/SVG/Content_type#Percentage) 值,那么这个值就代表了当前 viewport 的一个百分比。
> [!NOTE]
> 作为一个表现属性,`stroke-dashoffset` 可以用作 CSS 属性。

Gahotx marked this conversation as resolved.
Show resolved Hide resolved
值可以取为负值。

## 使用环境
## 用法

| 类别 | 显示属性 |
| ------ | ------------------------------------------------------------------------------------------------------------- |
| 值 | [\<percentage>](/zh-CN/SVG/Content_type#Percentage) \| [\<length>](/zh-CN/SVG/Content_type#Length) \| inherit |
| 初始值 | 1 |
| 可动画 | Yes |
| 初始值 | 0 |
| 可动画化 | 是 |
Gahotx marked this conversation as resolved.
Show resolved Hide resolved

偏移量通常根据 [<路径长度>](/zh-CN/SVG/Attribute/pathLength) 计算,但如果使用了一个 [<百分比>](/zh-CN/SVG/Content_type#Percentage) 值,那么这个值将表示为当前视口的百分比。

## 示例

```css hidden
html,
body,
svg {
height: 100%;
}
```

Gahotx marked this conversation as resolved.
Show resolved Hide resolved
```html
<svg viewBox="-3 0 33 10" xmlns="http://www.w3.org/2000/svg">
<!-- No dash array -->
Gahotx marked this conversation as resolved.
Show resolved Hide resolved
<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>
```

{{EmbedLiveSample("示例", '100%', 200)}}

## 元素

以下元素可使用 stroke-dashoffset 属性
Gahotx marked this conversation as resolved.
Show resolved Hide resolved

- [形状元素](/zh-CN/SVG/Element#Shape) »
- [文本内容元素](/zh-CN/SVG/Element#TextContent) »
- [形状元素](/zh-CN/SVG/Element#形状元素) »
- [文本内容元素](/zh-CN/SVG/Element#文本内容元素) »

## 规范

{{Specifications}}

## 浏览器兼容性

{{Compat}}
Loading