如何使用 CSS 指定元素應劃分為多少列


要指定元素應劃分為多少列,請使用 column-count 屬性。

你可以嘗試執行以下程式碼,用 4 列實現 column-count 屬性

示例

線上演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         .demo {
            column-count: 4;
         }
      </style>
   </head>
   <body>
      <div class = "demo">
         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>
   </body>
</html>

更新於: 2020 年 6 月 24 日

221 次瀏覽

開啟你的職業生涯

完成課程獲得認證

開始學習
廣告