首页 网络技术
  1. 正文

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

  <!DOCTYPEhtml><html><head>

  <metacharset="utf-8"/>

  <linkrel="stylesheet"href="GridMerge.css"/>

  <title></title>

  </head>

  <body>

  <divclass="Container">

  <divclass="GridItem1">内容1</div>

  <divclass="GridItem2">内容2</div>

  <divclass="GridItem3">内容3</div>

  <divclass="GridItem4">内容4</div>

  <divclass="GridItem5">内容5</div>

  <divclass="GridItem6">内容6</div>

  <divclass="GridItem7">内容7</div>

  <divclass="GridItem8">内容8</div>

  <divclass="GridItem9">内容9</div>

  <divclass="GridItem10">内容10</div>

  </div>

  </body>

  </html>

  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怎么在网格布局中创建多个网格的单元格
本文链接:https://www.qqooo.cn/post/6717.html
版权说明:网站文章均来源于手工整理和网友投稿,若有不妥之处请来信 xsds@vip.qq.com 处理,谢谢!