文章目录
1. grid 网格布局
- display:grid
- grid 属性是以下属性的简写属性,默认:
- grid-gap , none,【200px】网格之间的距离
- grid-template-rows, none , 行的尺寸
- grid-template-columns · ,none 【auto auto auto auto,有 几 列就设置几个】 ,列的宽度
- grid-template-areas· ,auto, 规定使用命名项目的网格布局
- grid-auto-rows , auto,行的尺寸(高度)
- grid-auto-columns. , auto,列的自动尺寸
- grid-auto-flow , row,如何放置自动就位的项目
- 常搭配css :
- justify-content 【对齐弹性容器的项目】属性用于在容器内对齐整个网格。
- align-content 属性用于垂直对齐容器内的整个网格。
- grid-column: 1 / 5;` Item1 将在 column 1 开始,并在 column 5 之间结束:
- grid-column: 1 / span 3;
- grid-row: 1 / 4;
- grid-row: 1 / span 2;
- grid-area: 1 / 2 / 5 / 6; 第1行第2列开始,第5行第6列结束
- grid-area: 2 / 1 / span 2 / span 3;第2行第1列开始,横跨2行3列
- grid-template-areas: ‘myArea myArea . . .’; 句号表示没有名称的网格项目
9.2 .如需定义两行,请在另一组撇号内定义第二行的列: grid-template-areas: ‘myArea myArea . . .’ ‘myArea myArea . . .’;