https://jsfiddle.net/3da02kxz/
Top example is the troublesome layout, bottom example is the expected layout.
Why does the .main
element (green) push the .side
element (blue) outside of .wrap
(orange)? I tried width/max-width/flex-basis/flex-grow on various elements but nothing really seems to stop it from doing that while allowing .main
to take up the available space. Setting max-width
on .main
to a specific value like 400px
helps, but obviously that’s not responsive.
2
Answers
It appears that a similar question was already answered and it solves my problem as well: Prevent flex items from overflowing a container
Simply adding
min-width: 0;
to.main
fixed it.Solution!
Just Give proper width to
.main
and.side elements
and place somediv
correctly follow the solution code given below 👇 Have any doubts feel free to ask!