【发布时间】:2020-03-28 09:16:57
【问题描述】:
我有一个非常简单的网格,带有标题和两列。网格有一个固定的宽度:300px,而旁边也有一个固定的宽度:100px。
如果我增加标题的min-width 比200px 更多,那么aside 部分会缩小。
为什么?据说,它可以增长到两列的宽度,而不改变其他列的宽度。
.container {
width: 300px;
display: grid;
grid-template-columns: minmax(0, max-content) auto;
grid-template-rows: max-content auto;
grid-template-areas: "header header"
"aside main";
}
header {
grid-area: header;
background-color: lightblue;
min-width: 250px;
/* Why if min-width > 200, then the aside shrinks?? */
}
aside {
grid-area: aside;
background-color: lightgreen;
width: 100px;
}
main {
grid-area: main;
background-color: lightpink;
}
<section class="container">
<header>
Header
</header>
<aside>
Aside
</aside>
<main>
Main
</main>
</section>
JSFiddle:https://jsfiddle.net/a1zto75g/
【问题讨论】:
-
嗯,
max-content就像上一个问题一样:stackoverflow.com/q/58978463/8620333 ...我想是时候重新阅读规范了 -
我不明白你的意思。同样的问题是 WITHOUT ``max-content```。 jsfiddle.net/ufh91kwd