Let me start by saying I'm not a frontend programmer, but sometimes you have to become one when the situation calls for it.
I've been pondering the behavior of flex or flexbox lately. If my usage is incorrect, please feel free to point it out to me. Thank you.
The Issue at Hand:
Recently, I attempted to create a basic layout using flexbox and encountered a problem. I'm not sure if it's a bug or if my expectations are too high, but I anticipate the same behavior in the following two cases.
https://jsfiddle.net/bargl_vojtech/upvb1Lgk/7/
https://jsfiddle.net/bargl\_vojtech/h7eokuua/1/
https://jsfiddle.net/bargl_vojtech/q0kegr8o/1/
Although they may look similar at first glance, a closer inspection reveals differences in the main
, #inside-main
in the CSS, and #wrapper
in the HTML.
Brief Overview:
main
- part of the view#main-header
- header for content (e.g., fixed title)#main-content
- scrollbox#inside-main
- endless content
I expected the second scenario to exhibit the same behavior as the first case. Can anyone explain why they differ?
Thank you for your input.
My expectation:
main
hasflex: 1
, so it should resize to fill the remaining parent size. However, somehow#inside-main
instructs#main-content
to resize itself (as it typically should... a larger inner div should resize a smaller parent div to match sizes). Because#main-content
is now larger than its parent, it then resizes that, creating a chain reaction. Shouldn’t this be overridden byoverflow: hidden/scroll
?