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-dasharray #23205

Merged
merged 6 commits into from
Aug 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 69 additions & 44 deletions files/zh-cn/web/svg/attribute/stroke-dasharray/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,93 @@ slug: Web/SVG/Attribute/stroke-dasharray

{{SVGRef}}

属性 `stroke-dasharray` 可控制用来描边的点划线的图案范式
**`stroke-dasharray`** 是一个表现属性,它定义了虚线段和间隙的长度
Gahotx marked this conversation as resolved.
Show resolved Hide resolved

作为一个外观属性,它也可以直接用作一个 CSS 样式表内部的属性。
> [!NOTE]
> 作为一个表现属性,`stroke-dasharray` 可以用作 CSS 属性。

## 用法

| 类别 | 外观属性 |
| ------ | ----------------------------------- |
| 值 | **none** \| \<dasharray> \| inherit |
| 可变性 | Yes |
你可以将此属性与以下 SVG 元素一起使用:

- \<dasharray>
- : 它是一个[\<length>](/zh-CN/SVG/Content_type#Length)和[\<percentage>](/zh-CN/SVG/Content_type#Percentage)数列,数与数之间用逗号或者空白隔开,指定短划线和缺口的长度。如果提供了奇数个值,则这个值的数列重复一次,从而变成偶数个值。因此,**5,3,2**等同于**5,3,2,5,3,2**。
- {{SVGElement('circle')}}
- {{SVGElement('ellipse')}}
- {{SVGElement('path')}}
- {{SVGElement('line')}}
- {{SVGElement('polygon')}}
- {{SVGElement('polyline')}}
- {{SVGElement('rect')}}
- {{SVGElement('text')}}
- {{SVGElement('textPath')}}
- {{SVGElement('tref')}}
- {{SVGElement('tspan')}}

## 示例

```html
<?xml version="1.0"?>
<svg
width="200"
height="200"
viewPort="0 0 200 300"
version="1.1"
xmlns="http://www.w3.org/2000/svg">
<line stroke-dasharray="5, 5" x1="10" y1="10" x2="190" y2="10" />
<line stroke-dasharray="5, 10" x1="10" y1="30" x2="190" y2="30" />
<line stroke-dasharray="10, 5" x1="10" y1="50" x2="190" y2="50" />
<line stroke-dasharray="5, 1" x1="10" y1="70" x2="190" y2="70" />
<line stroke-dasharray="1, 5" x1="10" y1="90" x2="190" y2="90" />
<line stroke-dasharray="0.9" x1="10" y1="110" x2="190" y2="110" />
<line stroke-dasharray="15, 10, 5" x1="10" y1="130" x2="190" y2="130" />
<line stroke-dasharray="15, 10, 5, 10" x1="10" y1="150" x2="190" y2="150" />
<line
stroke-dasharray="15, 10, 5, 10, 15"
x1="10"
y1="170"
x2="190"
y2="170" />
<line stroke-dasharray="5, 5, 1, 5" x1="10" y1="190" x2="190" y2="190" />
```css hidden
html,
body,
svg {
height: 100%;
}
```

```html
<svg viewBox="0 0 30 12" xmlns="http://www.w3.org/2000/svg">
<style>
<![CDATA[
line{
stroke: black;
stroke-width: 2;
line {
stroke: black;
}
]]>
</style>
<!-- 没有虚线和间隙 -->
<line x1="0" y1="1" x2="30" y2="1" />

<!-- 虚线段和间隙相同长度 -->
<line x1="0" y1="3" x2="30" y2="3" stroke-dasharray="4" />

<!-- 虚线段和间隙不同长度 -->
Gahotx marked this conversation as resolved.
Show resolved Hide resolved
<line x1="0" y1="5" x2="30" y2="5" stroke-dasharray="4 1" />

<!-- 具有奇数个各种长度的虚线段和间隙 -->
<line x1="0" y1="7" x2="30" y2="7" stroke-dasharray="4 1 2" />

<!-- 具有偶数个各种长度的虚线段和间隙 -->
Gahotx marked this conversation as resolved.
Show resolved Hide resolved
<line x1="0" y1="9" x2="30" y2="9" stroke-dasharray="4 1 2 3" />

<!-- 以间隙开始的虚线 -->
<line x1="0" y1="11" x2="30" y2="11" stroke-dasharray="0 4 0" />
</svg>
```

### 示例输出
{{EmbedLiveSample("示例", '100%', 150)}}

## 用法
Gahotx marked this conversation as resolved.
Show resolved Hide resolved

{{ EmbedLiveSample('示例','220','220') }}
<table class="properties">
<tbody>
<tr>
<th scope="row">值</th>
<td><code>none</code> | <code>&#x3C;dasharray></code></td>
</tr>
<tr>
<th scope="row">默认值</th>
<td><code>none</code></td>
</tr>
<tr>
<th scope="row">可动画化</th>
Gahotx marked this conversation as resolved.
Show resolved Hide resolved
<td>是</td>
</tr>
</tbody>
</table>

## 元素
- \<dasharray>

下列元素可以使用 `stroke-dasharray` 属性:
- : 以逗号或空格分隔的 [`<length>`](/zh-CN/docs/Web/SVG/Content_type#长度) 和 [`<percentage>`](/zh-CN/docs/Web/SVG/Content_type#百分数) 列表,用于定义交替的虚线段和间隙的长度。

- [形状元素](/zh-CN/SVG/Element#Shape_elements) »
- [文本内容元素](/zh-CN/SVG/Element#Text_content_elements) »
如果提供了奇数个值,则重复该列表以产生偶数个值,因此 `5,3,2` 等价于 `5,3,2,5,3,2`。

## 规范

{{Specifications}}

## 浏览器兼容性

{{Compat}}