grid-area:2/4/4/5; 第几行开始/第几列开始/到第几行结束/到第几列结束
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> * { padding: 0; margin: 0; } .parent { background: red; height: 200px;width: 800px;margin: 0 auto; display: grid; grid-template-rows: 1fr 1fr 1fr 1fr; grid-template-columns: 1fr 1fr 1fr 1fr; grid-gap: 5px 8px; } .parent div{background-color: pink} .div1 { grid-area: 1/1/3/3; background-color: red; } .div2 { grid-area:1/3/1/5 ; } .div3 { grid-area:2/3/4/4; } .div4 { grid-area:2/4/4/5; } .div5 { grid-area:3/1/5/3 ; } </style> </head> <body> <div class="parent"> <div class="div1">a111</div> <div class="div2">a222 </div> <div class="div3">a333 </div> <div class="div4">a4444 </div> <div class="div5"> a555</div> </div> </body> </html>
grid-area:2/4/4/5;标签:template,area,color,布局,网格,1fr,grid,background From: https://www.cnblogs.com/nice2018/p/17924254.html