HTML - DOM樣式物件borderBottomWidth屬性



HTML DOM 樣式物件**borderBottomWidth**屬性設定或返回元素的下邊框寬度。

語法

以下是獲取或設定borderBottomWidth屬性的語法。

設定borderBottomWidth屬性
object.style.borderBottomWidth= "thin | medium | thick | length | initial | inherit";
獲取borderBottomWidth屬性
object.style.borderBottomWidth;

屬性值

描述
thin 指定元素的細下邊框。
medium 預設值,指定元素的中等下邊框。
thick 指定元素的粗下邊框。
length 使用CSS測量單位(如px)指定下邊框寬度。
initial 用於將此屬性設定為其預設值。
inherit 用於繼承其父元素的屬性。

返回值

返回一個字串值,表示元素的下邊框寬度。

HTML DOM 樣式物件 'borderBottomWidth' 屬性示例

以下示例獲取和設定下邊框寬度。

設定元素的下邊框寬度

以下示例演示不同的下邊框寬度值,如“length”、“thin”、“medium”和“thick”。

<!DOCTYPE html>
<html lang="en">
<head>
    <Title>
        HTML DOM Style Object borderBottomWidth Property
    </Title>
    <style>
        h1 {
            border: solid 1px #04af2f;
        }
    </style>
</head>
<body>
    <p>Click to change the border style.</p>
    <button onclick="length()">Change Width</button>
    <button onclick="thin()">Thin</button>
    <button onclick="medium()">Medium</button>
    <button onclick="thick()">Thick</button>
    <h1 id="border">Welcome to Tutorials Point...</h1>
    <script>
        function length() {
            document.getElementById("border")
            .style.borderBottomWidth = "10px";
        }
        function thin() {
            document.getElementById("border")
            .style.borderBottomWidth = "thin";
        }
        function medium() {
            document.getElementById("border")
            .style.borderBottomWidth = "medium";
        }
        function thick() {
            document.getElementById("border")
            .style.borderBottomWidth = "thick";
        }
    </script>
</body>
</html>

獲取下邊框寬度值

以下示例返回左邊框寬度的值。

<!DOCTYPE html>
<html lang="en">
<head>
    <Title>
        HTML DOM Style Object borderBottomWidth Property
    </Title>
    <style>
        h1 {
            border: solid 1px #04af2f;
        }
    </style>
</head>
<body>
    <p>Click to change the border style.</p>
    <button onclick="length()">Change Width</button>
    <button onclick="thin()">Thin</button>
    <button onclick="medium()">Medium</button>
    <button onclick="thick()">Thick</button>
    <h1 id="border">Welcome to Tutorials Point...</h1>
    <p id="bottom"></p>
    <script>
        function length() {
            let x = document.getElementById("border")
                .style.borderBottomWidth = "10px";
            document.getElementById("bottom").innerHTML = x;
        }
        function thin() {
            let x = document.getElementById("border")
                .style.borderBottomWidth = "thin";
            document.getElementById("bottom").innerHTML = x;
        }
        function medium() {
            let x = document.getElementById("border")
                .style.borderBottomWidth = "medium";
            document.getElementById("bottom").innerHTML = x;
        }
        function thick() {
            let x = document.getElementById("border")
                .style.borderBottomWidth = "thick";
            document.getElementById("bottom").innerHTML = x;
        }
    </script>
</body>
</html>

支援的瀏覽器

屬性 Chrome Edge Firefox Safari Opera
borderBottomWidth 是 1 是 12 是 1 是 1 是 3.5
html_dom_style_object_reference.htm
廣告