HTML - DOM Style 物件 borderLeftStyle 屬性



HTML DOM Style 物件**borderLeftStyle**屬性設定或返回元素的左邊框樣式。

語法

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

設定 borderLeftStyle 屬性
object.style.borderLeftStyle= "none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset | initial | inherit";
獲取 borderLeftStyle 屬性
object.style.borderLeftStyle;

屬性值

描述
none 這是預設值,表示沒有邊框。
hidden 它與“none”相同,但它建立了一個透明或不可見的邊框,並佔用由邊框寬度指定的空間。它有助於解決表格元素中的邊框衝突。
dotted 它指定一個點狀邊框。
dashed 它指定一個虛線邊框。
solid 它指定一個實線邊框。
double 它定義一個雙線邊框,其中使用兩條線作為邊框,其寬度與 borderWidth 指定的寬度相同。
groove 它指定一個 3D 凹槽邊框,其效果取決於 border-color 值。
ridge 它指定一個 3D 凹槽邊框,其效果取決於 border-color 值。
inset 它指定一個 3D 內嵌邊框,其效果取決於 border-color 值。
outset 它指定一個 3D 外凸邊框,其效果取決於 border-color 值。
initial 它用於將此屬性設定為其預設值。
inherit 它用於繼承其父元素的屬性。

返回值

它返回一個字串值,表示元素的左邊框樣式。

HTML DOM Style 物件“borderLeftStyle”屬性的示例

以下示例說明了不同的左邊框樣式值。

更改左邊框樣式

在以下示例中,我們將左邊框樣式從點狀更改為實線。

<!DOCTYPE html>
<html>
<head>
    <title>
        HTML DOM Style Object borderLeftStyle Property
    </title>
    <style>
        #border {
            border: 2px dotted;
        }
    </style>
</head>
<body>
    <p>
        Click to change the border style.
    </p>
    <button onclick="fun()">Change Border</button>
    <section id="border">
        Welcome to Tutorials Point...
    </section>
    <script>
        function fun() {
            document.getElementById("border")
                .style.borderLeftStyle = "solid";
        }
    </script>
</body>
</html>

將左邊框樣式設定為“dotted”、“dashed”和“double”

以下示例將左邊框樣式設定為點狀、虛線和雙線。

<!DOCTYPE html>
<html lang="en">
<head>
    <Title>
        HTML DOM Style Object borderLeftStyle Property
    </Title>
    <style>
        h1 {
            border: 2px solid black;
        }
    </style>
</head>
<body>
    <p>Click to change the border style.</p>
    <button onclick="dotted()">Dotted</button>
    <button onclick="dashed()">Dashed</button>
    <button onclick="double()">Double</button>
    <h1 id="border">Welcome to Tutorials Point...</h1>
    <script>
        function dotted() {
            document.getElementById("border")
                .style.borderLeftStyle = "dotted";
        }
        function dashed() {
            document.getElementById("border")
                .style.borderLeftStyle = "dashed";
        }
        function double() {
            document.getElementById("border")
                .style.borderLeftStyle = "double";
        }
    </script>
</body>
</html>

將左邊框樣式設定為“groove”和“ridge”

以下示例將左邊框樣式設定為凹槽和脊狀。

<!DOCTYPE html>
<html lang="en">
<head>
    <Title>
        HTML DOM Style Object borderLeftStyle Property
    </Title>
    <style>
        h1 {
            border: 2px solid aqua;
        }
    </style>
</head>
<body>
    <p>
        Click to change the border style.
    </p>
    <button onclick="groove()">Groove</button>
    <button onclick="ridge()">Ridge</button>
    <h1 id="border">
        Welcome to Tutorials Point...
    </h1>
    <script>
        function groove() {
            document.getElementById("border")
                .style.borderLeftStyle = "groove";
        }
        function ridge() {
            document.getElementById("border")
                .style.borderLeftStyle = "ridge";
        }
    </script>
</body>
</html>

將左邊框樣式設定為“inset”和“outset”

以下示例將左邊框樣式設定為內嵌和外凸。

<!DOCTYPE html>
<html lang="en">
<head>
    <Title>
        HTML DOM Style Object borderLeftStyle Property
    </Title>
    <style>
        h1 {
            border: 2px solid aqua;
        }
    </style>
</head>
<body>
    <p>
        Click to change the border style.
    </p>
    <button onclick="inset()">Inset</button>
    <button onclick="outset()">Outset</button>
    <h1 id="border">
        Welcome to Tutorials Point...
    </h1>
    <script>
        function inset() {
            document.getElementById("border")
                .style.borderLeftStyle = "inset";
        }
        function outset() {
            document.getElementById("border")
                .style.borderLeftStyle = "outset";
        }
    </script>
</body>
</html>

支援的瀏覽器

屬性 Chrome Edge Firefox Safari Opera
borderLeftStyle 是 1 是 12 是 1 是 1 是 9.2
html_dom_style_object_reference.htm
廣告