HTML - DOM Style 物件 columnRuleWidth 屬性



HTML DOM Style 物件 **columnRuleWidth** 屬性用於設定或獲取列之間的規則寬度。

語法

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

屬性值

描述
thin 它指定列之間細線。
medium 這是預設值,它指定列之間中等粗細的線。
thick 它指定列之間粗線。
length 它以 CSS 測量單位(如 px)設定列之間的規則。
initial 它用於將此屬性設定為其預設值。
inherit 它用於繼承其父元素的屬性。

返回值

它返回一個字串值,表示元素的列規則寬度屬性。

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

以下示例設定了列規則寬度的不同值。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object columnRuleWidth Property
    </title>
    <style>
        #rule {
            column-count: 3;
            column-rule: 2px solid #04af2f;
        }
    </style>
</head>
<body>
    <p>Click to change the rule width.</p>
    <button onclick="fun()">Thin</button>
    <button onclick="funtwo()">Medium</button>
    <button onclick="funthree()">Thick </button>
    <button onclick="funfour()">Change Length</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.columnRuleWidth = "thin";
        }
        function funtwo() {
            document.getElementById("rule")
                .style.columnRuleWidth = "medium";
        }
        function funthree() {
            document.getElementById("rule")
                .style.columnRuleWidth = "thick";
        }
        function funfour() {
            document.getElementById("rule")
                .style.columnRuleWidth = "10px";
        }
    </script>
</body>
</html>

支援的瀏覽器

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