CSS Multi-column
- Previous Page CSS Pagination
- Next Page CSS User Interface
CSS 多列布局
CSS 多列布局允许我们轻松定义多列文本 - 就像报纸那样:
三国演义
第一回
宴桃园豪杰三结义
斩黄巾英雄首立功
话说天下大势,分久必合,合久必分:周末七国分争,并入于秦;及秦灭之后,楚、汉分争,又并入于汉;汉朝自高祖斩白蛇而起义,一统天下,后来光武中兴,传至献帝,遂分为三国。推其致乱之由,殆始于桓、灵二帝。桓帝禁锢善类,崇信宦官。及桓帝崩,灵帝即位,大将军窦武、太傅陈蕃,共相辅佐;时有宦官曹节等弄权,窦武、陈蕃谋诛之,机事不密,反为所害,中涓自此愈横。建宁二年四月望日,帝御温德殿。方升座,殿角狂风骤起,只见一条大青蛇,从梁上飞将下来,蟠于椅上。帝惊倒,左右急救入宫,百官俱奔避。须臾,蛇不见了。忽然大雷大雨,加以冰雹,落到半夜方止,坏却房屋无数。建宁四年二月,洛阳地震;又海水泛溢,沿海居民,尽被大浪卷入海中。光和元年,雌鸡化雄。六月朔,黑气十馀丈,飞入温德殿中。秋七月,有虹现于玉堂,五原山岸,尽皆崩裂。种种不祥,非止一端。帝下诏问群臣以灾异之由,议郎蔡邕上疏,以为蜺堕鸡化,乃妇寺干政之所致,言颇切直。帝览奏叹息,因起更衣。曹节在后窃视,悉宣告左右;遂以他事陷邕于罪,放归田里。后张让、赵忠、封谞、段珪、曹节、侯览、蹇硕、程旷、夏恽、郭胜十人朋比为奸,号为“十常侍”。帝尊信张让,呼为“阿父”。朝政日非,以致天下人心思乱,盗贼蜂起。
...... ......
CSS Multi-column Properties
In this chapter, you will learn the following multi-column properties:
column-count
column-gap
column-rule-style
column-rule-width
column-rule-color
column-rule
column-span
column-width
Browser Support
The numbers in the table indicate the first browser version that fully supports this property.
Property | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
column-count | 50.0 | 10.0 | 52.0 | 9.0 | 37.0 |
column-gap | 50.0 | 10.0 | 52.0 | 9.0 | 37.0 |
column-rule | 50.0 | 10.0 | 52.0 | 9.0 | 37.0 |
column-rule-color | 50.0 | 10.0 | 52.0 | 9.0 | 37.0 |
column-rule-style | 50.0 | 10.0 | 52.0 | 9.0 | 37.0 |
column-rule-width | 50.0 | 10.0 | 52.0 | 9.0 | 37.0 |
column-span | 50.0 | 10.0 | 71.0 | 9.0 | 37.0 |
column-width | 50.0 | 10.0 | 52.0 | 9.0 | 37.0 |
CSS Create Multi-column
column-count
Property specifies the number of columns the element should be divided into.
The following example divides the text within the <div> element into 3 columns:
Example
div { column-count: 3; }
CSS Specify Column Gap
column-gap
Property specifies the interval between columns.
The following example specifies that the gap between columns should be 40 pixels:
Example
div { column-gap: 40px; }
CSS Column Rule
column-rule-style
Property specifies the style of the rule between columns:
Example
div { column-rule-style: solid; }
column-rule-width
Property specifies the width of the rule between columns:
Example
div { column-rule-width: 1px; }
column-rule-color
Property specifies the color of the rule between columns:
Example
div { column-rule-color: lightblue; }
The column-rule property is a shorthand attribute used to set all the column-rule-* properties mentioned above.
The following example sets the width, style, and color of the rule between columns:
Example
div { column-rule: 1px solid lightblue; }
Specify how many columns the element should span
column-span
Property specifies how many columns the element should span.
The following example specifies that the <h2> element should span all columns:
Example
h2 { column-span: all; }
Specify column width
column-width
Property specifies the suggested best width for columns.
The following example specifies that the suggested best width for columns should be 100px:
Example
div { column-width: 100px; }
CSS Multi-column Properties
The following table lists all multi-column properties:
Property | Description |
---|---|
column-count | Define the number of columns that the element should be divided into. |
column-fill | Define how columns are filled. |
column-gap | Specify the gap between columns. |
column-rule | Used to set the shorthand attribute for all column-rule-* properties. |
column-rule-color | Define the color of the rule between columns. |
column-rule-style | Define the rule style between columns. |
column-rule-width | Define the rule width between columns. |
column-span | Specify how many columns an element should span. |
column-width | Specify the recommended best width for the columns. |
columns | Abbreviated properties for setting column-width and column-count. |
- Previous Page CSS Pagination
- Next Page CSS User Interface