如何使用 JavaScript 設定列之間的間距寬度?


使用 columnRuleWidth 屬性可以設定列之間的寬度。你可以嘗試執行以下程式碼,使用 JavaScript 設定列之間的間距寬度 −

示例

現場演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         #myID {
            column-count: 4;
            column-rule: 4px solid yellow;
         }
      </style>
   </head>
   <body>
      <p>Click below to change width</p>
      <button onclick="display()">Change Width between 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.columnRuleWidth = "8px";
         }
      </script>
   </body>
</html>

更新於: 2020年6月23日

85瀏覽

開啟您的 事業

完成課程,獲取認證

開始
廣告
© . All rights reserved.