スタイルアウトラインプロパティ
例
<div>要素の周りにアウトラインを追加します。
document.getElementById("myDiv").style.outline = "thick solid #0000FF";
定義と使用法
アウトラインプロパティは、すべてのアウトラインプロパティを省略形で設定または返します。
このプロパティを使用すると、次の1つ以上を(任意の順序で)設定/返すことができます。
- アウトライン幅
- アウトラインスタイル
- アウトラインカラー
アウトラインは、要素の周りの線です。要素の余白の周りに表示されます。ただし、borderプロパティとは異なります。
アウトラインは要素の寸法の一部ではないため、要素の幅と高さのプロパティにはアウトラインの幅が含まれていません。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
outline | Yes | Yes | Yes | Yes | Yes |
構文
アウトラインプロパティを返します。
object.style.outline
アウトラインプロパティを設定します。
object.style.outline = "width style color|initial|inherit"
プロパティ値
Parameter | Description |
---|---|
width | Sets the width of the outline |
style | Sets the style of the outline |
color | Sets the color of the outline |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
技術的な詳細
デフォルト値: | ミディアムなし反転 |
---|---|
戻り値: | 要素の輪郭の幅、スタイル、色を表す文字列 |
CSSバージョン | CSS2 |
その他の例
例
<div>要素のアウトラインの幅、スタイル、色を変更します。
document.getElementById("myDiv").style.outline = "5px dotted green";
例
<div>要素のoutlineプロパティ値を返します。
alert(document.getElementById("myDiv").style.outline);
関連ページ
CSSチュートリアル:CSSの概要
CSSリファレンス:アウトラインプロパティ
❮スタイルオブジェクト