<feDropShadow>
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2020年1月.
<feDropShadow> は SVG のフィルタープリミティブで、入力画像のドロップシャドウを作成します。これは、<filter> 要素内でのみ使用できます。
メモ:
ドロップシャドウの色と透明度は、flood-color および flood-opacity というプレゼンテーション属性を使用して変更できます。
他のフィルタープリミティブと同様に、デフォルトで linearRGB 色空間の色成分を処理します。color-interpolation-filters を使用することで、代わりに sRGB を使用することも可能です。
使用コンテキスト
属性
dx: この属性はドロップシャドウの x オフセットを定義します。 値の型: <number>; デフォルト値:2; アニメーション: 可dy: この属性はドロップシャドウの y オフセットを定義します。 値の型: <number>; デフォルト値:2; アニメーション: 可instdDeviation: この属性は、ドロップシャドウのぼかし処理における標準偏差を定義します。 値の型: <number-optional-number>; デフォルト値:2; アニメーション: 可- フィルタープリミティブ属性:
x,y,width,height,result
DOM インターフェイス
この要素は SVGFEDropShadowElement インターフェイスを実装しています。
例
html
<svg viewBox="0 0 30 10" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="shadow">
<feDropShadow dx="0.2" dy="0.4" stdDeviation="0.2" />
</filter>
<filter id="shadow2">
<feDropShadow dx="0" dy="0" stdDeviation="0.5" flood-color="cyan" />
</filter>
<filter id="shadow3">
<feDropShadow
dx="-0.8"
dy="-0.8"
stdDeviation="0"
flood-color="pink"
flood-opacity="0.5" />
</filter>
</defs>
<circle cx="5" cy="50%" r="4" fill="pink" filter="url(#shadow)" />
<circle cx="15" cy="50%" r="4" fill="pink" filter="url(#shadow2)" />
<circle cx="25" cy="50%" r="4" fill="pink" filter="url(#shadow3)" />
</svg>
仕様書
| Specification |
|---|
| Filter Effects Module Level 1> # feDropShadowElement> |
ブラウザーの互換性
関連情報
- SVG フィルタープリミティブ属性、例えば
height,in,result,x,y,width - SVG プレゼンテーション属性、例えば
flood-color,flood-opacity.