如何用 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.