代码
提交代码
<!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 100px; grid-template-rows:100px 100px; border:1px solid #eee } .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 class="item">4</div> </div> 慕课网学习 </body> </html>
运行结果