I have a flex element that has three divs .
ββββββββββββββββββββββββββββββββββββββββββ | WRAPPER | | βββββββββββ¬ββββββββββββ¬βββββββββββ | | | LEFT | CENTER | RIGHT | | | | | | | | | βββββββββββ΄ββββββββββββ΄βββββββββββ | ββββββββββββββββββββββββββββββββββββββββββ
And I want to move the center column to the next row on small screens (less than 600 pixels). It should occupy 100% of the screen width.
The problem is that when the center column moves to the next row, the right column does not fit into the wrapper.
Here is my HTML code:
<div id="wrapper"> <div class="block left">Left</div> <div class="block center">Center</div> <div class="block right">Right</div> </div>
Here is my CSS code:
html, body{ height: 100%; } body{ margin: 0; } #wrapper{ display: flex; width: 100%; height: 50px; align-items: center; text-align: center; } .block{ height: 50px; } .left{ width: 20%; background-color: red; order: 1; } .center{ width: 60%; background-color: green; order: 2; } .right{ width: 20%; background-color: blue; order: 3; } @media all and (max-width: 600px) { #wrapper{ flex-flow:column wrap; height: 100px; } .center { width: 100%; order: 3; } .left{ width: 50%; } }
JSFiddle where you can see how it is displayed.
Is it possible to move the middle column to the next row, occupying 100% of the screen width, using flexbox ? If so, what am I missing?
Thanks in advance!
css flexbox css3
Francisco romero
source share