.grid-item { grid-column-start: 2; grid-column-end: 5; }
<div class="grid-container"> <div class="grid-item item1">Item 1</div> <div class="grid-item item2">Item 2</div> <div class="grid-item item3">Item 3</div> <div class="grid-item item4">Item 4</div> </div>
.grid-container { display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: auto; gap: 10px; } .grid-item { background-color: #f2f2f2; padding: 10px; text-align: center; } .item1 { grid-column-start: 1; grid-column-end: 2; } .item2 { grid-column-start: 2; grid-column-end: 3; } .item3 { grid-column-start: 2; grid-column-end: 4; } .item4 { grid-column-start: 1; grid-column-end: 4; }
本文为翻滚的胖子原创文章,转载无需和我联系,但请注明来自猿教程iskeys.com