HTML DOM borderWidth 屬性
定義和用法
borderWidth 屬性設(shè)置所有四個邊框的寬度。
該屬性可使用 1 到 4 個值:
- 如果規(guī)定一個值,比如 div {border-width: thick} - 所有四個邊框都是粗線。
- 如果規(guī)定兩個值,比如 div {border-width: thick thin} - 上下邊框是粗線,而左右邊框是細(xì)線。
- 如果規(guī)定三個值,比如 div {border-width: thick thin medium}- 上邊框是粗線,左右邊框是細(xì)線,下邊框是中等 (medium) 的寬度。
- 如果規(guī)定四個值,比如 div {border-width: thick thin medium 10px} - 上邊框是粗線,右邊框是細(xì)線,下邊框是中等的寬度,而左邊框是 10px 的寬度。
語法:
Object.style.borderWidth=thin|medium|thick|length
可能的值:
值 | 描述 |
---|---|
thin | 定義細(xì)的下邊框。 |
medium | 默認(rèn)。定義中等的下邊框。 |
thick | 定義粗的下邊框。 |
length | 允許您自定義下邊框的寬度。 |
實例
本例改變邊框的寬度:
<html>
<head>
<style type="text/css">
p
{
border: thin solid #FF0000
}
</style>
<script type="text/javascript">
function changeBorderWidth()
{
document.getElementById("p1").style.borderWidth="thick thin";
}
</script>
</head>
<body>
<input type="button" onclick="changeBorderWidth()"
value="Change border widths" />
<p id="p1">This is a paragraph</p>
</body>
</html>