【发布时间】:2020-07-18 01:51:22
【问题描述】:
我使用 CSS 网格创建了一个 12 列的网格。但是,现在我坚持使用 auto width (Auto expand until the end) 类。谁能告诉我有什么办法或解决方法来实现它?
.box {background-color: #20262e; color: #fff; padding: 2rem;}
.row {
display: grid;
grid-gap: 1rem;
grid-template-columns: repeat(12, 1fr);
}
.col-6 {
grid-column-end: span 6;
}
.col-2 {
grid-column-end: span 2;
}
.col {
background-color: red !important;
/* ??? */
}
<div class="row">
<div class="box col-6">Parent A</div>
<div class="box col-6">
<div class="row">
<div class="box col-6">Child A</div>
<div class="box col-6">Child B</div>
</div>
</div>
<div class="box col-2">A</div>
<div class="box col">AUTO FILL</div>
<div class="box col-2">B</div>
</div>
【问题讨论】:
-
这是一个 flexbox 工作,你不能用 CSS 网格来做到这一点