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>