HTML - DOM Style 物件 columnSpan 屬性



HTML DOM Style 物件 **columnSpan** 屬性用於定義元素應跨越的列數。

語法

設定 columnSpan 屬性
object.style.columnSpan= "1 | all | initial | inherit";
獲取 columnSpan 屬性
object.style.columnSpan;

屬性值

描述
1 這是預設值,指定元素跨越一列。
all 指定元素跨越所有列。
initial 用於將此屬性設定為其預設值。
inherit 用於繼承其父元素的屬性。

返回值

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

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

在以下示例中,h2 元素跨越所有列。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object columnSpan Property
    </title>
    <style>
        #color {
            column-count: 3;
        }
    </style>
</head>
<body>
    <button onclick="fun()">Click</button>
    <div id="color">
    <h2 id="colspan">
        HTML DOM Style Object columnSpan Property  With
        Column Count 3 Spanning Over all Column
    </h2>
    <p >
        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>
    </div>
    <script>
        function fun() {
            document.getElementById("colspan")
                .style.columnSpan = "all";
        }
    </script>
</body>
</html>

支援的瀏覽器

屬性 Chrome Edge Firefox Safari Opera
columnSpan 是 50 是 12 是 71 是 9 是 37
html_dom_style_object_reference.htm
廣告