How to set the gap between the columns with JavaScript?

JavascriptWeb DevelopmentFront End Scripts

To set the gap between columns, use the columnGap property.

Example

You can try to run the following code to learn how to set the gap between columns with JavaScript −

Live Demo

<!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>
raja
Published on 27-Feb-2018 11:30:56
Advertisements