admin管理员组文章数量:1332890
I have a between keyboard and chair issue with CSS flexbox when nesting two flexboxes.
The body
of my HTML document is a flexbox occupying exactly the viewport, so that main
can stretch to what header
does not take. The header includes a navigation, that I put into a wrapping flexbox.
Everything works as intended in the portrait setup with navigation on top (body
is flex-flow: column nowrap
and the ul
in header
is flex-flow: row wrap
).
However, in landscape design (body
is flex-flow: row nowrap
and ul
m flex-flow: column wrap
), the ul
overflow in x unless I manually set its width.
Here is a minimal code displaying the unintended behaviour under firefox 131.
* {
margin: 0;
box-sizing: border-box;
}
body {
display: flex;
flex-flow: row nowrap;
width: 100vw;
height: 100vh;
}
main {
flex: 1 0;
}
/* Header overflows in x when flex ul wraps instead of adapting its width. Desired behaviour only if I set ul width manually. */
header {
background: DimGrey;
height: 100%;
overflow-x: scroll;
}
ul {
display: flex;
flex-flow: column wrap;
height: 100%;
}
li {
list-style: none;
padding: 2ex;
margin: .5ex;
background: white;
}
<header>
<ul>
<li>A</li>
<li>B</li>
<li>C</li>
<li>D</li>
<li>E</li>
<li>F</li>
</ul>
</header>
<main>
<h1>Flex column wrap inside flex row wrap</h1>
</main>
本文标签: flexboxCSS flex column wrap inside flex rowStack Overflow
版权声明:本文标题:flexbox - CSS flex column wrap inside flex row - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742317693a2452147.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论