html - How to wrap containers to fit below the top containers when window width decreases in bootstrap 4? -


i new bootstrap 4 , haven't worked on bootstrap 3 either.

when assign class col-(breakpoint)-(span) div(s), don't automatically arrange in single row or adjust according width of window, instead remain left aligned , stacked on top of 1 another. assign css flex property parent container , trick.

now make these wrap according window size assign classes according bootstrap 4 grid system, not make containers wrap next row. instead combined width of flex-items exceeds width of window, enabling sideways(x-axis) scroll.

what want first 2 containers remain in 1 row , last 2 wrap row on smaller screen widths(phone portrait, <576px).

 <div style="display:flex;">     <div class="col-sm-3 col-6"></div>     <div class="col-sm-3 col-6"></div>     <div class="col-sm-3 col-6"></div>     <div class="col-sm-3 col-6"></div>  </div> 

where going wrong?

use necesarry grid classes, see docs https://getbootstrap.com/docs/4.0/layout/grid/

you have wrap cols in row , rows in container (.container or .container-fluid)

<div class="container">   <div class="row">     <div class="col-sm-3 col-6">x</div>     <div class="col-sm-3 col-6">y</div>     <div class="col-sm-3 col-6">z</div>     <div class="col-sm-3 col-6">a</div>   </div> </div> 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -