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