如何使用 CSS 指定元素应划分的列数

cssweb developmentfront end technology更新于 2024/8/14 9:48:17

要指定元素应划分的列数,请使用 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>

相关文章


有用资源