HTML - DOM樣式物件 borderImageOutset 屬性



HTML DOM 樣式物件 **borderImageOutset** 屬性指定邊框影像區域超出邊框框的程度。

語法

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

設定 borderImageOutset 屬性
object.style.borderImageOutset= "length | number | initial | inherit";
獲取 borderImageOutset 屬性
object.style.borderImageOutset;

屬性值

描述
長度 (length) 它指定影像從邊框框延伸的距離。它最多接受 4 個值,每個值對應一個邊。如果省略第四個值,則其值將與第二個值相同;如果省略第三個值,則其值將與第一個值相同;如果省略第二個值,則其值將與第一個值相同。
數字 (number) 它指定邊框寬度的倍數。它接受十進位制值。
初始值 (initial) 用於將此屬性設定為其預設值。
繼承 (inherit) 用於繼承其父元素的屬性。

返回值

它返回一個字串值,表示元素的 border image outset 屬性。

HTML DOM 樣式物件“borderImageOutset”屬性的示例

以下示例演示瞭如何為每一側新增和設定邊框影像突出。

新增邊框影像突出

以下示例添加了邊框影像突出。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object borderImageOutset Property
    </title>
    <style>
        #outset {
            border: 20px solid transparent;
            margin: 20px;
            border-image: url("/tensorflow/images/tensorflow.jpg") 30 round;
            border-image-outset: 5px;
            background-color: #04af2f;
        }
    </style>
</head>
<body>
    <p>Change Outset</p>
    <button onclick="fun()">
        Change Border Outset
    </button>
    <br><br><br>
    <p id="outset">
        This is a sample paragraph containing some text. This
        paragraph is created only for the sake of this example.
    </p>
    <script>
        function fun() {
            document.getElementById("outset")
                .style.borderImageOutset = "20px";
        }
    </script>
</body>
</html>

為每一側設定邊框影像突出

以下示例根據單擊的按鈕為每一側設定邊框影像突出。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object borderImageOutset Property
    </title>
    <style>
        #outset {
            border: 20px solid transparent;
            margin: 20px;
            border-image: url("/tensorflow/images/tensorflow.jpg") 30 round;
            border-image-outset: 5px;
            background-color: #04af2f;
        }
    </style>
</head>
<body>
    <p>Change Outset</p>
    <button onclick="fun()">Change</button>
    <button onclick="funTwo()">Two</button>
    <button onclick="funThree()">Three</button>
    <button onclick="funFour()">Four</button>
    <br><br><br>
    <p id="outset">
        This is a sample paragraph containing some text. This
        paragraph is created only for the sake of this example.
    </p>
    <script>
        function fun() {
            document.getElementById("outset")
                .style.borderImageOutset = "20px";
        }
        function funTwo() {
            document.getElementById("outset")
                .style.borderImageOutset = "20px 10px";
        }
        function funThree() {
            document.getElementById("outset")
                .style.borderImageOutset = "20px 10px 30px";
        }
        function funFour() {
            document.getElementById("outset")
                .style.borderImageOutset = "20px 10px 30px 40px";
        }
    </script>
</body>
</html>

使用“數字”設定邊框影像突出

以下示例使用 number 屬性值(接受十進位制數)設定邊框影像突出。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object borderImageOutset Property
    </title>
    <style>
        #outset {
            border: 20px solid transparent;
            margin: 20px;
            border-image: url("/tensorflow/images/tensorflow.jpg") 30 round;
            border-image-outset: 5px;
            background-color: #04af2f;
        }
    </style>
</head>
<body>
    <p>Change Outset</p>
    <button onclick="fun()">Change</button>
    <br><br><br>
    <p id="outset">
        This is a sample paragraph containing some text. This
        paragraph is created only for the sake of this example.
    </p>
    <script>
        function fun() {
            document.getElementById("outset")
                .style.borderImageOutset = "2.3";
        }
    </script>
</body>
</html>

支援的瀏覽器

屬性 Chrome Edge Firefox Safari Opera
borderImageOutset 是 15 是 12 是 11 是 6 是 15
html_dom_style_object_reference.htm
廣告