天天看點

Style border 屬性

Style border 屬性

Style 對象

border 屬性以速記形式設定或傳回三個獨立的邊框屬性。

通過該屬性,您可以設定/傳回:

border-width

border-style

border-color

設定 border 屬性:

Object.style.border="width style color"

傳回 border 屬性:

Object.style.border

<b>提示:</b>border 屬性沒有預設值。

參數

描述

width

設定邊框的寬度。

style

設定邊框的樣式。

color

設定邊框的顔色。

Style border 屬性
Style border 屬性
Style border 屬性
Style border 屬性
Style border 屬性

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

更改 div 元素的邊框:

&lt;!DOCTYPE html&gt;

&lt;html&gt;

&lt;head&gt;

&lt;meta charset="utf-8"&gt;

&lt;title&gt;菜鳥教程(runoob.com)&lt;/title&gt;

&lt;style type="text/css"&gt;

#ex1{

    border: thin dotted #FF0000;

}

&lt;/style&gt;

&lt;script&gt;

function displayResult(){

    document.getElementById("ex1").style.border="thick solid #0000FF";

&lt;/script&gt;

&lt;/head&gt;

&lt;body&gt;

&lt;div id="ex1"&gt;這是一些文本。&lt;/div&gt;

&lt;br&gt;

&lt;button type="button" onclick="displayResult()"&gt;修改邊框&lt;/button&gt;

&lt;/body&gt;

&lt;/html&gt;

Style border 屬性