示例
html
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<!-- Lines materialized the position of the glyphs -->
<line x1="10%" x2="10%" y1="0" y2="100%" />
<line x1="0" x2="100%" y1="30%" y2="30%" />
<line x1="0" x2="100%" y1="80%" y2="80%" />
<!-- Some reference text -->
<text x="10%" y="30%" fill="grey">SVG</text>
<!-- The same text with a shift along the y-axis -->
<text dy="50%" x="10%" y="30%">SVG</text>
</svg>
css
line {
stroke: red;
stroke-width: 0.5px;
stroke-dasharray: 3px;
}
feDropShadow
對於 <feDropShadow>,dy 定義了投射陰影的 y 軸偏移量。用於解析該屬性值的單位由 <filter> 元素的 primitiveUnits 屬性設定。
| 值 | <number> |
|---|---|
| 預設值 | 2 |
| 可動畫的 | 是 |
feOffset
對於 <feOffset>,dy 定義了濾鏡輸入圖形的 y 軸偏移量。用於解析該屬性值的單位由 <filter> 元素的 primitiveUnits 屬性設定。
| 值 | <number> |
|---|---|
| 預設值 | 0 |
| 可動畫的 | 是 |
文字
對於 <text>,如果它包含單個值,dy 定義了所有字形的 y 軸偏移量。
如果有多個值,dy 定義了每個字形相對於前一個字形在 y 軸上的偏移量。如果值少於字形數量,則其餘字形使用 0 值。如果值多於字形數量,則忽略多餘的值。
| 值 | 列表(<length> | <percentage>) |
|---|---|
| 預設值 | none |
| 可動畫的 | 是 |
示例
html
<svg viewBox="0 0 150 100" xmlns="http://www.w3.org/2000/svg">
<!-- Horizontal lines -->
<line x1="0" x2="100%" y1="30" y2="30" />
<line x1="0" x2="100%" y1="40" y2="40" />
<line x1="0" x2="100%" y1="50" y2="50" />
<line x1="0" x2="100%" y1="60" y2="60" />
<!-- Vertical lines -->
<line x1="10" x2="10" y1="0" y2="100%" />
<line x1="50" x2="50" y1="0" y2="100%" />
<line x1="90" x2="90" y1="0" y2="100%" />
<!-- Behaviors change based on the number of values in the attributes -->
<text dy="20" x="10" y="30">SVG</text>
<text dy="0 10" x="50" y="30">SVG</text>
<text dy="0 10 20" x="90" y="30">SVG</text>
</svg>
css
line {
stroke: red;
stroke-width: 0.5px;
stroke-dasharray: 3px;
}
tspan
對於 <tspan>,如果它包含單個值,dy 定義了所有備用字形在 y 軸上的偏移量。
如果有多個值,dy 定義了每個字形相對於前一個字形在 y 軸上的偏移量。如果值少於字形數量,則其餘字形使用 0 值。如果值多於字形數量,則忽略多餘的值。
| 值 | 列表(<length> | <percentage>) |
|---|---|
| 預設值 | none |
| 可動畫的 | 是 |
規範
| 規範 |
|---|
| 濾鏡效果模組第 1 級 # element-attrdef-fedropshadow-dy |
| 濾鏡效果模組第 1 級 # element-attrdef-feoffset-dy |
| Scalable Vector Graphics (SVG) 2 # TextElementDYAttribute |