Get the App
SLTechnology News&Howtos  ›  Development  › 

How does HTML create multiple grid cells in a grid layout

Shulou Source: shulou.com Published: 2022-06-01 04:46:44 10月05日 Update

本文小编为大家详细介绍"HTML怎么在网格布局中创建多个网格的单元格",内容详细,步骤清晰,细节处理妥当,希望这篇"HTML怎么在网格布局中创建多个网格的单元格"文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。

说明:

上面的橙色单元格是grid-column:1/6;grid-row:1/2;

左边的蓝色单元格grid-column:1/3;grid-row:2/4;

正确的绿色单元格是grid-column:3/6;grid-row:2/3;

左下方的灰色单元格是grid-column:1/3;grid-row:4/5;

右下方的黄色单元格是grid-column:3/6;grid-row:3/5;

下面的白色单元格是

grid-column:1/2;grid-row:5/6;

grid-column:2/3;grid-row:5/6;

grid-column:3/4;grid-row:5/6;

grid-column:4/5;grid-row:5/6;

grid-column:5/6;grid-row:5/6;

下面将上述布局写入网格单元格的类中。

代码如下

编写以下HTML,CSS。

SimpleGrid.html

内容1

内容2

内容3

内容4

内容5

内容6

内容7

内容8

内容9

内容10

SimpleGrid.css

.Container{

display:grid;

grid-template-columns:160px160px160px160px160px;

grid-template-rows:120px120px120px120px120px;

border:solid#ff6a001px;

}

.GridItem1{

grid-column:1/6;

grid-row:1/2;

background-color:#ff9c9c;

}

.GridItem2{

grid-column:1/3;

grid-row:2/4;

background-color:#ffcb70;

}

.GridItem3{

grid-column:1/3;

grid-row:4/5;

background-color:#7ee68d;

}

.GridItem4{

grid-column:3/6;

grid-row:2/3;

background-color:#7ee6e2;

}

.GridItem5{

grid-column:3/6;

grid-row:3/5;

background-color:#95a7f5;

}

.GridItem6{

grid-column:1/2;

grid-row:5/6;

background-color:#d095f5;

}

.GridItem7{

grid-column:2/3;

grid-row:5/6;

background-color:#e1bbfa;

}

.GridItem8{

grid-column:3/4;

grid-row:5/6;

background-color:#d2b1e4;

}

.GridItem9{

grid-column:4/5;

grid-row:5/6;

background-color:#dcd2e1;

}

.GridItem10{

grid-column:5/6;

grid-row:5/6;

background-color:#eee8f1;

}

读到这里,这篇"HTML怎么在网格布局中创建多个网格的单元格"文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注行业资讯频道。

Tags: Content unit grid layout multiple medium creation article face proper code idea new knowledge more orange step gray white knowledge knowledge point article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Docker Linux Shulou Technology vpn