您好,欢迎访问一九零五行业门户网

CSS3网格布局基础知识

网格布局支持弹性尺寸(flex-size),这是一个很好的自适应布局技术。
弹性尺寸使用fr尺寸单位,其来自 fraction 或 fractional unit 单词的前两个字母,表示整体空间的一部分。
比如下面的css规则:
grid-template-columns: 100px 1fr max-content minmax(min-content, 1fr);
表示有4列,第一列100px固定尺寸,第三列 max-content 代表刚好包含元素不溢出不换行的尺寸,剩下的2列都是弹性尺寸。
按照弹性尺寸的计算规则,两者将均分(这两列的弹性系数相等,均为1)剩下的可用空间。
完整示范代码:
#grid { display: grid; width: 100%; grid-template-columns: 100px 1fr max-content minmax(min-content, 1fr);}#areaa { background-color: lime;}#areab { background-color: yellow;}#areac { background-color: lime;}#aread { background-color: orange;}#areaa { background-color: green;}div { height: 80px; line-height: 80px; text-align: center;}
site logo
slogan
user zone

你可以自己试试看:http://wow.techbrood.com/fiddle/15917
by iefreer
其它类似信息

推荐信息