【发布时间】:2020-09-04 22:53:53
【问题描述】:
我有一个关于 CSS 网格的问题。假设我有 2 行:
第一行:
<div class="first-row">
<div>
Col 1
</div>
<div>
Col 2
</div>
<div>
Col 3
</div>
<div>
Col 4
</div>
</div>
第二行:
<div class="second-row">
<div>
<span>Under Col 1</span>
</div>
<div>
<span>Under Col 2</span>
</div>
<div class"SPLIT-THIS">
<span>Under Col 3</span>
<span>Under Col 4</span>
</div>
</div>
如何拆分第二行中的最后一个 div 元素,以便第一行的内容与第二行的内容完全对齐(就像它们在结构上是相同的行一样)。
我使用的CCS:
.first-row {
grid-template-columns: repeat(4, 1fr);
grid-gap: 20px;
align-items: center;
justify-content: center;
text-align: center;
}
.second-row {
grid-template-columns: repeat(3, 1fr);
grid-gap: 20px;
align-items: center;
justify-content: center;
text-align: center;
}
【问题讨论】: