【发布时间】:2021-01-20 12:30:06
【问题描述】:
所以我创建了一个两列的网格,使左边的项目与右边的项目对齐,并编写了以下代码:
article {
display: grid;
grid-template-areas:
'reading wt'
'reading wt'
'reading wt'
'reading wt'
'reading wt'
'reading wt';
}
文章包含 12 个 div 元素,前六个有这个 css:
.reading {
grid-column: reading;
}
对于最后六个,grid-column 设置为 wt。
问题是,结果看起来不像我预期的那样:the items of the wt column start on the sixth row and keep going down, extending the grid.
将 grid-row 设置为 1 / 6 可以预见地使它们都位于第一行。我猜你可以为每个 div 写一个单独的规则来明确告诉它应该放在哪里,但必须有更好的解决方案,对吧?
【问题讨论】:
-
请添加一个 sn-p 或 fiddle 链接以及您的问题的工作示例,以便我们更好地帮助您
-
试试这个
grid-template-rows: auto;和/或grid-template-columns: 50% 50%; -
@Kyojimaru 完成
-
@RaRaRitalin 不幸没有工作
标签: css