Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Javascript

จะกำหนดความกว้างของกฎระหว่างคอลัมน์ด้วย 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>