如何使用 JavaScript 設定列規則屬性?


columnRule 屬性用於在 JavaScript 中設定列規則。它允許你設定列規則之間的樣式、顏色和寬度。

示例

你可以嘗試執行以下程式碼在 JavaScript 中設定列規則屬性 −

即時演示

<!DOCTYPE html>
<html>
   <body>
      <p>Click below to create 4 columns</p>
      <button onclick="display()">Columns</button>
      <div id="myID">
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
      </div>
      <script>
         function display() {
            document.getElementById("myID").style.columnCount = "4";
            document.getElementById("myID").style.columnRule = "2px outset red";
         }
      </script>
   </body>
</html>

更新於: 2020 年 6 月 23 日

143 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.