CSSborder -widthプロパティ
例
境界線の幅を設定します。
div {border-width: thin;}
以下の「自分で試してみてください」の例をもっと見てください。
定義と使用法
このborder-width
プロパティは、要素の4つの境界線の幅を設定します。このプロパティには、1〜4個の値を指定できます。
例:
- border-width:薄い中程度の厚い10px;
- 上縁が薄い
- 右の境界線は中程度です
- 下の境界線が太い
- 左の境界線は10pxです
- ボーダー幅:薄い中程度の厚さ。
- 上縁が薄い
- 左右の境界線は中程度です
- 下の境界線が太い
- ボーダー幅:薄いミディアム;
- 上と下の境界線は細い
- 左右の境界線は中程度です
- ボーダー幅:薄い;
- 4つの境界線はすべて細い
注:プロパティの前に必ずborder-styleborder-width
プロパティを宣言してください
。幅を設定する前に、要素に境界線が必要です。
デフォルト値: | 中くらい |
---|---|
遺伝性の: | いいえ |
アニメート可能: | はい。アニメート可能について読む |
バージョン: | CSS1 |
JavaScript構文: | object .style.borderWidth = "1px 5px" |
ブラウザのサポート
表の数字は、プロパティを完全にサポートする最初のブラウザバージョンを示しています。
Property | |||||
---|---|---|---|---|---|
border-width | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
CSS構文
border-width: medium|thin|thick|length|initial|inherit;
プロパティ値
Value | Description | Play it |
---|---|---|
medium | Specifies a medium border. This is default | |
thin | Specifies a thin border | |
thick | Specifies a thick border | |
length | Allows you to define the thickness of the border. Read about length units | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
その他の例
例
境界線の幅を中程度に設定します。
div {border-width: medium;}
例
境界線の幅を太く設定します。
div {border-width: thick;}
例
境界線の幅を1pxに設定します。
div {border-width: 1px;}
例
境界線の幅を15pxに設定します。
div {border-width: 15px;}
例
上下の境界線の幅を10pxに設定し、左右の境界線の幅を1pxに設定します。
div {border-width: 10px 1px;}
関連ページ
CSSチュートリアル:CSS Border
HTML DOMリファレンス: borderWidthプロパティ