代码
提交代码
<!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> .demo{ display:grid; grid-template-columns: 100px auto 100px; grid-template-rows:100px; color:#fff; text-align: center; } .item:nth-of-type(1){ background: red; } .item:nth-of-type(2){ background: green; } .item:nth-of-type(3){ background: purple; } </style> </head> <body> <div class="demo"> <div class="item">1</div> <div class="item">2</div> <div class="item">3</div> </div> </body> </html>
运行结果