paint-order
Baseline
広く利用可能
この機能は広く実装されており、多くのバージョンの端末やブラウザーで動作します。2020年1月以降、すべてのブラウザーで利用可能です。
paint-order 属性は、指定された図形またはテキスト要素の塗りつぶし、輪郭、マーカーを描画する順序を指定します。
メモ:
プレゼンテーション属性である paint-order には、対応する CSS プロパティ paint-order があります。両方が指定された場合、CSS プロパティが優先されます。
この属性は、次の SVG 要素で使用できます。
例
html
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="200">
<linearGradient id="g" x1="0" y1="0" x2="0" y2="1">
<stop stop-color="#888888" />
<stop stop-color="#cccccc" offset="1" />
</linearGradient>
<rect width="400" height="200" fill="url(#g)" />
<g
fill="crimson"
stroke="white"
stroke-width="6"
stroke-linejoin="round"
text-anchor="middle"
font-family="sans-serif"
font-size="50px"
font-weight="bold">
<text x="200" y="75">前面輪郭</text>
<text x="200" y="150" paint-order="stroke" id="stroke-under">背面輪郭</text>
</g>
</svg>
この例は次のようにレンダリングされます。

輪郭を背面に配置する効果は、次の CSS プロパティで実現できます。
css
#stroke-under {
paint-order: stroke;
}
使用上のメモ
| 値 |
normal | [ fill || stroke ||
markers ]
|
|---|---|
| デフォルト値 | normal |
| アニメーション | 離散 |
- normal
-
塗りつぶし、輪郭、マーカーの順に描画します。
- [ fill || stroke || markers ]
-
これらの 3 つのキーワードの順序は、描画が行われる順序を左から右へ示します。 3 つの描画要素のうちいずれかを省略した場合、省略された要素は指定された要素の後に既定の順序で描画されます。例えば、
strokeを使用することはstroke fill markersと同等です。
仕様書
| 仕様書 |
|---|
| Scalable Vector Graphics (SVG) 2> # PaintOrderProperty> |