Grid网格布局
Posted ljming
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Grid网格布局相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>网格布局</title> <style> .container { display: grid; grid-template-columns: 100px 100px 100px 100px 100px; grid-template-rows: 100px 100px 100px 100px 100px; } .item { background-color: #0fc; color: #fff; font-size: 150%; padding: 20px; margin: 10px; } .item-1 { grid-column-start: 1; grid-column-end: 5; grid-row-start: 1; grid-row-end: 2; } .item-2 { grid-column-start: 1; grid-column-end: 2; grid-row-start: 2; grid-row-end: 5; } .item-3 { grid-column-start: 2; grid-column-end: 4; grid-row-start: 2; grid-row-end: 3; } .item-4 { grid-column-start: 2; grid-column-end: 4; grid-row-start: 3; grid-row-end: 4; } .item-5 { grid-column-start: 2; grid-column-end: 4; grid-row-start: 4; grid-row-end: 5; } .item-6 { grid-column-start: 4; grid-column-end: 5; grid-row-start: 2; grid-row-end: 5; } </style> </head> <body> <h1>Grid布局</h1> <div class="container"> <div class="item item-1">1</div> <div class="item item-2">2</div> <div class="item item-3">3</div> <div class="item item-4">4</div> <div class="item item-5">5</div> <div class="item item-6">6</div> </body> </html>
以上是关于Grid网格布局的主要内容,如果未能解决你的问题,请参考以下文章