天天看點

Style borderStyle 屬性

Style 對象

定義和用法

borderStyle 屬性設定或傳回元素邊框的樣式。

該屬性可使用 1 到 4 種樣式:

  • 如果規定一種樣式,比如:p {border-style: solid} - 所有四個邊框都是實線。
  • 如果規定兩種樣式,比如:p {border-style: solid dotted} - 上邊框和下邊框是實線,而左邊框和右邊框是點狀。
  • 如果規定三種樣式,比如:p {border-style: solid dotted double}- 上邊框是實線,左邊框和右邊框是點狀,下邊框是雙線。
  • 如果規定四種樣式,比如:p {border-style: solid dotted double dashed} - 上邊框是實線,右邊框是點狀,下邊框是雙線,左邊框是虛線。

文法

設定 borderStyle 屬性:

Object.style.borderStyle="value"

傳回 borderStyle 屬性:

Object.style.borderStyle

描述
none 預設。定義無邊框。
hidden 與 "none" 相同。不過應用于表時除外,對于表,hidden 用于解決邊框沖突。
dotted 定義點狀邊框。
dashed 定義虛線邊框。
solid 定義實線邊框。
double 定義雙線邊框。雙線的寬度等于 border-width 的值。
groove 定義 3D 凹槽邊框。其效果取決于 border-color 的值。
ridge 定義 3D 壟狀邊框。其效果取決于 border-color 的值。
inset 定義 3D inset 邊框。其效果取決于 border-color 的值。
outset 定義 3D outset 邊框。其效果取決于 border-color 的值。
inherit 邊框的樣式從父元素繼承。

浏覽器支援

Style borderStyle 屬性
Style borderStyle 屬性
Style borderStyle 屬性
Style borderStyle 屬性
Style borderStyle 屬性

所有主要浏覽器都支援 borderStyle 屬性。

注意:

IE7 及更早的版本不支援 "inherit" 值。IE8 隻有規定了 !DOCTYPE 才支援 "inherit"。IE9 支援 "inherit"。

執行個體

更改四個邊框的樣式:

<html>

<head>

<style type="text/css">

#ex1

{

border: thick solid #FF0000;

}

</style>

<script>

function displayResult()

document.getElementById("ex1").style.borderStyle="dotted double";

</script>

</head>

<body>

<div id="ex1">This is some text.</div>

<br>

<button type="button" onclick="displayResult()">Change style of

the four

borders</button>

</body>

</html>

Style 對象