Nested flexbox doesn't render correctly
See original GitHub issueHi,
I have encountered a problem with nested flexbox that I can’t figure out how to solve. If I use simple flexbox, everything works as expected, but when I try to nest them, strange things starts to happens.
Here is the most simplified example I could come up with:
#paper {
width: 148mm;
height: 105mm;
display: flex;
flex-direction: column;
}
#content {
width: 100%;
display: flex;
flex-direction: column;
flex: auto;
justify-content: space-between;
}
#header {
width: 100%;
height: 2cm;
}
<div id="paper">
<div id="header" style="background-color:lightblue">Header part, should be full width, 2 cm height</div>
<div id="content">
<div style="background-color:orange" class="toppart">
Middle part, should be 100% width, blank space should follow thanks to justify-items: between.
</div>
<div class="bottompart" style="background-color:yellow">
Bottom part. Should be 100% width, blank space before.
</div>
</div>
</div>
The expected result should look something like this:
But the actual result looks like this:
I couldn’t find similar bug, so I’m reporting it here, sorry if it is a duplicate. Is there anything I could do to help fix this issue?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Nested flexbox not expanding - Stack Overflow
When I set .header-cell3and4 to have flex: 1 instead of display: flex it messes up the positioning of my images inside the cell....
Read more >Updates to DOM elements are extremely slow when nested ...
I'm working on a web app that allows the user to dynamically grid up the space in their window. Essentially, the body is...
Read more >Nested Components in a Design System - CSS-Tricks
Let's make components that are both reusable and responsive when there are nested components within components.
Read more >Two Issues Styling the Details Element and How to Solve Them
Nesting a block-level element (e.g. a heading) inside a <summary> ... In other words, it probably doesn't hurt to put a heading there....
Read more >z-index - CSS-Tricks
Also note that nesting plays a big role. If an element B sits on top of ... Just being position: relative doesn't start...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Another (simple) example, I believe:
HTML+CSS
Expected layout
WeasyPrint PDF
WeasyPrint layout
Adding the following doesn’t help PDF output much either.
Swapping out the nested flexbox for a grid doesn’t render as expected too:
HTML+CSS
WeasyPrint PDF
Hello, I’m also seeing this issue and have tested with version 54.0b1. The elements within my nested flexbox are not filling the width of my parent. As @sharicahill mentioned, the only workaround is to manually set the with of my elements … however this is not ideal as some of my elements are dynamic is size.