Bootstrap Columns In Flexbox Not Wrapping On Smaller Screens
Solution 1:
There are two things you should consider:
When you apply
display: flex
to an element it becomes a flex container which comes with several default styles.One of the defaults is
flex-direction: row
, which aligns flex items (child elements) along the horizontal axis. To switch to a vertical direction you need to specifyflex-direction: column
.Another default is
flex-wrap: nowrap
, which forces flex items to remain on a single line (even if they overflow the container).From your question:
The problem is that with the flex style properties, when the window is <768px ideally the content would change layout and each
col-md-4
would stack on top of one another. This is not happening, instead the columns just become really skinny and are displayed still side by side.It sounds like the flex items are not wrapping. Try adding this to the flex container:
flex-wrap: wrap;
If you want the flex items to stack vertically when the window is < 768px, use a media query with the
flex-direction
property.@media screen and (max-width: 768px) { .your-selector-here {flex-direction: column;} }
Note on browser support:
Flexbox is supported by all major browsers, except IE < 10. Some recent browser versions, such as Safari 8 and IE10, require vendor prefixes. For a quick way to add prefixes use Autoprefixer. More details in this answer.
Post a Comment for "Bootstrap Columns In Flexbox Not Wrapping On Smaller Screens"