首页
CSS
CSS 网格项目
尝试:五个项目的网格布局
运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> .grid-container { display: grid; gap: 10px; background-color: #2196F3; padding: 10px; } .grid-item { background-color: rgba(255, 255, 255, 0.8); text-align: center; padding: 20px; font-size: 30px; } .item1 { grid-column: 1 / span 2; grid-row: 1; } .item2 { grid-column: 3; grid-row: 1 / span 2; } .item5 { grid-column: 1 / span 3; grid-row: 3; } </style> </head> <body> <h1>A Five Items Grid Layout</h1> <div class="grid-container"> <div class="grid-item item1">1</div> <div class="grid-item item2">2</div> <div class="grid-item item3">3</div> <div class="grid-item item4">4</div> <div class="grid-item item5">5</div> </div> <p>Direct child elements(s) of the grid container automatically becomes grid items.</p> <p>Item 1, 2, and 5 are set to span multiple columns or rows.</p> </body> </html>