HTML - DOM樣式物件columnRule屬性



HTML DOM樣式物件columnRule屬性設定或返回列規則屬性。它是列之間規則的寬度、樣式和顏色的簡寫表示。

語法

設定columnRule屬性
object.style.columnRule= "column-rule-width | column-rule-style | column-rule-color | initial | inherit";
獲取columnRule屬性
object.style.columnRule;

屬性值

描述
columnRuleWidth 設定列之間的規則寬度。其預設值為medium。
columnRuleStyle 設定列之間的規則樣式。其預設值為none。
columnRuleColor 設定列之間的規則顏色。其預設值為元素的顏色。
initial 用於將此屬性設定為其預設值。
inherit 用於繼承其父元素的屬性。

返回值

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

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

下面的例子演示了columnRule屬性,它在列之間添加了一個綠色的點狀規則。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object columnRule Property
    </title>
    <style>
        #rule {
            column-count: 3;
        }
    </style>
</head>
<body>
    <button onclick="fun()">Change</button>
    <p id="rule">
        CSS is the acronym for "Cascading Style Sheet".
        It's a style sheet language used for describing
        the presentation of a document written in a markup
        language like HTML. CSS helps the web developers to
        control the layout and other visual aspects of the
        web pages. CSS plays a crucial role in modern web
        development by providing the tools necessary to create
        visually appealing, accessible, and responsive websites.
    </p>
    <script>
        function fun() {
            document.getElementById("rule")
                .style.columnRule = "5px dotted #04af2f";
        }
    </script>
</body>
</html>

支援的瀏覽器

屬性 Chrome Edge Firefox Safari Opera
columnRule 是 50 是 12 是 52 是 9 是 11.1
html_dom_style_object_reference.htm
廣告