每行的不同列大小(网格)

发布于 2025-02-07 09:41:00 字数 228 浏览 2 评论 0原文

我在布局中使用CSS网格... 如何在第一行上设置不同的列大小,并在第二行上设置全宽度? 这可能吗?

非常感谢!!!

I am using CSS Grid in my layout...
How do I set different column size on first row and full width on second row?
Is this possible?
enter image description here

Thank you so much!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桃酥萝莉 2025-02-14 09:41:00

这是不可能的,CSS网格的想法是具有“网格”,即所有行都遵循相同的列配置。

但是,您可以做的是要有一个元素跨越几列,在这里您有几个选择:

从第一列到第一列从第一个列到第一个列,

div:nth-child(3) {
  grid-column: 1 / -1;
}

从第一列跨越第一个列:

div:nth-child(3) {
  grid-column: 1 / span 2;
}

This is not possible, the idea of css grid is to have a "grid", that is all the rows follow the same column configuration.

What you can do however is have an element span several column, and here you have several options:

This one stretches from the first column to the first from the end

div:nth-child(3) {
  grid-column: 1 / -1;
}

This one spans 2 columns from the first one:

div:nth-child(3) {
  grid-column: 1 / span 2;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文