Style textShadowプロパティ
Style オブジェクト
定義と使い方
textShadow プロパティは、1つ以上のテキストシャドウ効果を設定または返します。
構文
textShadow プロパティを設定する:
Object.style.textShadow="none|h-shadow v-shadow blur color|inherit"
注意:textShadow プロパティは、テキストに1つ以上のシャドウを付加します。このプロパティはカンマ区切りのシャドウリストであり、各値は2つまたは3つの長さの値とオプションの色で指定されます。省略された長さは0になります。
textShadow プロパティを返す:
Object.style.textShadow
| 值 | 説明 |
|---|---|
| none | デフォルト。シャドウは描画されません。 |
| h-shadow | 必須。水平方向のシャドウの位置。負の値を使用できます。 |
| v-shadow | 必須。垂直方向のシャドウの位置。負の値を使用できます。 |
| blur | オプション。ぼかし距離。 |
| color | オプション。シャドウの色。CSS 色の値で、可能な色の値の完全なリストを参照してください。 |
| inherit | textShadow プロパティの値は親要素から継承されます。 |
ブラウザ対応
![]()
![]()
![]()
![]()
![]()
Internet Explorer を除くすべての主要ブラウザが textShadow プロパティをサポートしています。
例
例
テキストにシャドウを追加する:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function displayResult(){
document.getElementById("p1").style.textShadow="5px 5px 1px #ff0000,10px 10px 1px #0000ff";
}
</script>
</head>
<body>
<p id="p1">これは一部のテキストです。</p>
<br>
<button type="button" onclick="displayResult()">テキストにシャドウを追加</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function displayResult(){
document.getElementById("p1").style.textShadow="5px 5px 1px #ff0000,10px 10px 1px #0000ff";
}
</script>
</head>
<body>
<p id="p1">これは一部のテキストです。</p>
<br>
<button type="button" onclick="displayResult()">テキストにシャドウを追加</button>
</body>
</html>
試してみる »
Style オブジェクト その他の拡張