当前位置: 首页 > 文档资料 > CSS 入门教程 >

CSS3 - 多列(CSS3 - Multi columns)

优质
小牛编辑
120浏览
2023-12-01

CSS3支持多列将文本排列为新闻纸结构。

一些最常用的多列属性如下所示 -

Sr.No.价值和描述
1

column-count

用于计算元素应划分的列数。

2

column-fill

用于决定如何填充列。

3

column-gap

用于决定列之间的差距。

4

column-rule

用于指定规则的数量。

5

rule-color

用于指定列规则颜色。

6

rule-style

用于指定列的样式规则。

7

rule-width

用于指定宽度。

8

column-span

用于指定列之间的跨度。

例子 (Example)

下面的例子显示了文本作为新纸张结构的排列。

<html>
   <head>
      <style>
         .multi {
            /* Column count property */
            -webkit-column-count: 4;
            -moz-column-count: 4;
            column-count: 4;
            /* Column gap property */
            -webkit-column-gap: 40px; 
            -moz-column-gap: 40px; 
            column-gap: 40px;
            /* Column style property */
            -webkit-column-rule-style: solid; 
            -moz-column-rule-style: solid; 
            column-rule-style: solid;
         }
      </style>
   </head>
   <body>
      <div class = "multi">
         xnip originated from the idea that there exists a class 
         of readers who respond better to online content and prefer to learn 
         new skills at their own pace from the comforts of their drawing rooms.
         The journey commenced with a single tutorial on HTML in 2006 and elated 
         by the response it generated, we worked our way to adding fresh tutorials
         to our repository which now proudly flaunts a wealth of tutorials and 
         allied articles on topics ranging from programming languages to web 
         designing to academics and much more.
      </div>
   </body>
</html>

假设,如果用户想要将文本作为没有行的新论文,我们可以通过删除样式语法来完成此操作,如下所示 -

.multi {
   /* Column count property */
   -webkit-column-count: 4;
   -moz-column-count: 4;
   column-count: 4;
   /* Column gap property */
   -webkit-column-gap: 40px; 
   -moz-column-gap: 40px; 
   column-gap: 40px;
}