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


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

示例

你可以嘗試執行以下程式碼,使用 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.