div를 세 개의 열로 나누려면 columnCount를 사용하세요. 재산. 열 개수를 설정하고 div를 나눕니다.
예시
다음 코드를 실행하여 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"; } </script> </body> </html>