如何用JavaScript填充列?
使用columnFill属性填充列。将其填充为自动以顺序填充,或平衡以在列之间平均分配内容。
示例
您可以尝试运行以下代码以使用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"; document.getElementById("myID").style.columnFill = "balance"; } </script> </body> </html>