Blogger Information
Blog 17
fans 1
comment 0
visits 8767
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
CSS之grid常用的9大属性
P粉933302309
Original
467 people have browsed it

CSS-grid常用的9大属性

1.创建grid网格
  1. /* grid建立网格 */
  2. display: grid;
2.grid-template-columns/rows显示生成网格单元
  1. /* 创建3列.宽高10em */
  2. grid-template-columns: repeat(3, 10em);
  3. /* 创建3行,宽高10em*/
  4. grid-template-rows: repeat(3, 10em);
3.grid-area :将项目放到指定单元格中
  1. /* 项目将在行 2 列 1 开始,并横跨 2 行 3 列 */
  2. grid-area: 2 / 1 / span 2 / span 3;
4.grid-auto-flow:行与列的排列规则
  1. /* 行优先 */
  2. grid-auto-flow: row;
  3. /* 列优先 */
  4. grid-auto-flow: column;

行优先

列优先

5.grid-auto-row/column:隐式网格的行列的大小
  1. grid-auto-rows: 5em;
  2. grid-auto-column: 5em;

效果图

6.gap:行列间隙
  1. /* gap:行间距 列间距 */
  2. gap: 5px 10px;

效果图

7.place-content:所有项目在容器中的对齐方式
  1. place-content: center end;

效果图

8.place-items: 所有项目在网格单元格中的对其方式
  1. /*所有项目在容器中居中对齐*/
  2. place-items: center;

9.place-self:某个项目在网格单元中的对齐方式
  1. .container > .ltem:nth-last-of-type(5) {
  2. place-self: end end;
  3. }

效果图

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post