HTML - DOM Style 物件 columnGap 屬性



HTML DOM Style 物件 **columnGap** 屬性用於指定列之間的間隙。

語法

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

屬性值

描述
length 它以長度單位設定間隙。
normal 這是預設值,為多列布局指定列之間 1em 的間隙。
initial 它用於將此屬性設定為其預設值。
inherit 它用於繼承其父元素的屬性。

返回值

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

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

以下示例將列間距設定為 45px。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object columnGap Property
    </title>
    <style>
        #gap {
            column-count: 3;
        }
    </style>
</head>
<body>
    <p>Click to change the gap distance.</p>
    <button onclick="fun()">Change</button>
    <p id="gap">
        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("gap")
                .style.columnGap = "45px";
        }
    </script>
</body>
</html>

支援的瀏覽器

屬性 Chrome Edge Firefox Safari Opera
columnGap 是 1 是 12 是 1.5 是 3 是 11.1
html_dom_style_object_reference.htm
廣告