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

จะกำหนดช่องว่างระหว่างคอลัมน์ด้วย JavaScript ได้อย่างไร?


ในการกำหนดช่องว่างระหว่างคอลัมน์ ให้ใช้ columnGap ทรัพย์สิน

ตัวอย่าง

คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อเรียนรู้วิธีตั้งค่าช่องว่างระหว่างคอลัมน์ด้วย JavaScript -

<!DOCTYPE html>
<html>
   <body>
      <p>Click below to create 4 columns and set gap of 30px</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.columnGap = "30px";
         }
      </script>
   </body>
</html>