HTML - DOM Style 物件 borderImageSource 屬性



HTML DOM Style 物件 **borderImageSource** 屬性用於設定或返回用作元素邊框影像的影像源。

語法

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

設定 borderImageSource 屬性
object.style.borderImageSource= "none | image | initial | inherit";
獲取 borderImageSource 屬性
object.style.borderImageSource;

屬性值

描述
none 這是預設值,表示不使用邊框影像。如果指定了邊框樣式,則將使用邊框樣式。
image 它表示用作邊框影像的影像路徑。
initial 用於將此屬性設定為其預設值。
inherit 用於繼承其父元素的屬性。

返回值

它返回一個字串值,表示元素的邊框影像重複源。

HTML DOM Style 物件“borderImageSource”屬性示例

在以下示例中,我們使用 borderImageSource 屬性添加了一個邊框影像。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object borderImageSource Property
    </title>
    <style>
        #source {
            border: 20px solid transparent;
            margin: 20px;
            border-image: 30 round;
        }
    </style>
</head>
<body>
    <p>Click to add image</p>
    <button onclick="fun()">Add</button>
    <br><br><br>
    <p id="source">
        This is a sample paragraph containing some 
        text. This paragraph is created only for example.
    </p>
    <p id="ex"></p>
    <script>
        function fun() {
            document.getElementById("source")
                .style.borderImageSource = 
                    "url(/images/blockchain.png)";
            document.getElementById("ex").innerHTML=x;
        }
    </script>
</body>
</html>

支援的瀏覽器

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