Grid宫格布局

	// 固定数量和宽度
	display: grid;
	grid-template-columns: 90px 100px 110px;
	grid-template-rows: 110px 100px 90px;
	// 固定数量,宽度自适应
	display: grid;
	grid-template-columns: repeat(3, 33.33%);
	grid-template-rows: repeat(3, 33.33%);
	// 固定宽度,数量自适应
	display: grid;
	grid-template-columns: repeat(auto-fill, 100px);

auto-fit,内容将被拉伸以填满整个行的宽度。
auto-fill,浏览器将允许空列像它们的非空邻居一样占据行中的空间–即使它们中没有网格项,也会被分配一部分空间

	display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, auto));
    grid-template-columns: repeat(auto-fit, minmax(120px, auto)); // 各网格宽度自动分配
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); // 各网格宽度平均分配
    grid-template-columns: repeat(auto-fit, minmax(120px, 0.25fr)); // 各网格宽度平均分配(最大1/4)
    grid-gap: 9px 30px;
	// 设置间距
	grid-row-gap: 20px;
	grid-column-gap: 20px;
	// 也可以使用 justify-content 属性和 align-content 属性
	justify-items 属性,
	align-items 属性,设置单元格对齐方式
	place-items 属性是align-items属性和justify-items属性的合并简写形式。

顺序由grid-auto-flow属性决定,默认值是row,即"先行后列"。也可以将它设成column,变成"先列后行"。

	// grid-template-areas 配合 grid-area 一起使用
	// 指定网格定义区域
	grid-template-areas: 'a b c'
	                     'e f g'
	                     'h i j';

	// 多个单元格合并成一个区域的写法如下。
	// 如果某些区域不需要利用,则使用"点"(.)表示。
	grid-template-areas: 'a a b'
	                     'c . b'
	                     'c d d';
	// 指定网格所在区域
	grid-area:a;
	

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值