【发布时间】:2021-06-24 12:42:31
【问题描述】:
这是我现在拥有的:
.post {
display: grid;
gap: 2rem;
}
.post div:nth-child(1) {
grid-area: 1 / 1;
}
.post div:nth-child(2) {
grid-area: 1 / 2 / 1 / 2;
}
.post div:nth-child(3) {
grid-area: 1 / 3;
}
<div class="post">
<div class="post__id">
<p>001</p>
</div>
<div class="post__body">
<a href="..."><p>Lorem ipsum</p></a>
<p>text…</p>
</div>
<div class="post__date">
<p>01.01.2021</p>
</div>
</div>
有没有像下面的单元格填充文本一样扩展中间单元格以占用最大空间的好方法?
P.S.:解决这个问题的一种方法:
.post {
display: grid;
gap: 2rem;
grid-template-columns: 1fr 1000fr 1fr;
}
/* and comment out the rest of the above code */
但我认为这不是一个好的解决方案……
【问题讨论】: