CSS Grid布局-响应式网格
html公开前 25 行,完整代码需登录
<style>
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 10px;
background-color: #e8e8e8;
padding: 10px;
}
.grid-item {
background-color: #2196F3;
border: 1px solid #000;
color: white;
font-size: 24px;
font-weight: bold;
text-align: center;
min-height: 100px;
display: flex;
align-items: center;
justify-content: center;
}
</style>
<div class="grid">
<div class="grid-item">1</div>
<div class="grid-item">2</div>
<div class="grid-item">3</div>