Style outlineWidthプロパティ
Style オブジェクト
定義と使い方
outlineWidth プロパティは、要素の周囲のアウトラインの幅を設定または返します。
構文
outlineWidth プロパティを設定する:
Object.style.outlineWidth="thin|medium|thick|length|inherit"
outlineWidth プロパティを返す:
Object.style.outlineWidth
| 值 | 説明 |
|---|---|
| thin | 細いアウトラインを定義します。 |
| medium | デフォルト。中程度のアウトラインを定義します。 |
| thick | 太いアウトラインを定義します。 |
| length | px、cm などの単位を使用してアウトラインの幅を定義します。 |
| inherit | アウトラインの幅は親要素から継承されます。 |
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザは outlineWidth プロパティをサポートしています。
注意:IE7 およびそれ以前のバージョンは outlineWidth プロパティをサポートしていません。IE8 は !DOCTYPE が指定されている場合のみ outlineWidth プロパティをサポートします。IE9 は outlineWidth プロパティをサポートしています。
ヒントと注記
アウトラインは要素の周囲を囲む線です。要素の margin の周囲に表示されます。ただし、border プロパティとは異なります。
アウトラインは要素の寸法の一部ではないため、要素の width および height プロパティにはアウトラインの幅は含まれません。
例
例
アウトラインの幅を変更する:
<html>
<head>
<style type="text/css">
#ex1
{
border:1px solid red;
outline:green dotted thick;
}
</style>
<script>
function displayResult()
{
document.getElementById("ex1").style.outlineWidth="10px";
}
</script>
</head>
<body>
<div id="ex1">This is some text.</div>
<br>
<button type="button" onclick="displayResult()">Change outline width</button>
</body>
</html>
<head>
<style type="text/css">
#ex1
{
border:1px solid red;
outline:green dotted thick;
}
</style>
<script>
function displayResult()
{
document.getElementById("ex1").style.outlineWidth="10px";
}
</script>
</head>
<body>
<div id="ex1">This is some text.</div>
<br>
<button type="button" onclick="displayResult()">Change outline width</button>
</body>
</html>
試してみる »
Style オブジェクト その他の拡張