📜  CSS columns属性

📅  最后修改于: 2020-11-05 02:29:10             🧑  作者: Mango

CSS columns

CSS中的columns属性设置单个声明中的列数和宽度。这是一种简写属性,一次可以包含多个值。

它用于同时设置列数和列宽属性。这两个属性均用于控制将显示多少列。 column-count属性用于设置列数,而column-width属性指定列的宽度。

一起使用column-count和column-width属性可创建多列布局,该布局可在不使用媒体查询的情况下以狭窄的浏览器宽度自动分成单个列。同时使用它们并不总是有帮助的,因为这会限制布局的响应性和灵活性。

如果列数和宽度不适合元素的宽度,则浏览器会自动减少列数以适合指定的列宽。

句法

columns: auto | column-width column-count| initial | inherit;    

属性值

属性值及其描述如下表所示。

Value Description
auto It is the default value which sets the values of column-count and column-width to the default browser values.
column-width It is used to set the minimum width for columns. However, the actual width of the column may be narrower or wider based on the available space.
column-count It specifies the maximum number of columns.
Initial It is used to set the property to its default value.
Inherit It inherits the property from its parent element.

如果省略任何值,则默认情况下,浏览器将假定对应的值为auto。

在此示例中,我们定义了两个

元素,包括文字。对于第一个div元素,最小宽度为100px,最大为no。的列可以是四个。而第二个div元素的最小宽度为100px,最大为。的列可以是六个。








The columns Property

The columns property is a shorthand property for column-width and column-count

Set the column-width to 100px, and column-count 4

Hi, Welcome to the javaTpoint.com. This site is developed so that students may learn computer science related technologies easily. The javaTpoint.com is committed to providing easy and in-depth tutorials on various technologies. Here, you will find lots of tutorials that are easy to understand and learn. No one is perfect in this world, and nothing is eternally best. But we can try to be better.

Set the column-width to 100px, and column-count to 6

Hi, Welcome to the javaTpoint.com. This site is developed so that students may learn computer science related technologies easily. The javaTpoint.com is committed to providing easy and in-depth tutorials on various technologies. Here, you will find lots of tutorials that are easy to understand and learn. No one is perfect in this world, and nothing is eternally best. But we can try to be better.

输出量