I am having a problem when practice web-design with HTML, CSS using Bootstrap v5.0.
Particularly, I have 3 divs A,B,C and I want them to responsively reorder as in the picture below. A is a h2 + p, B is 2 buttons, and C is an image.
My first approach was to group A and B into a col-lg-6 and C into another col-lg-6, but this way is inappropriate since the code must follow the order A-C-B to have the mobile view as in the picture.
I have searched and tried multiple posts about this problem on StackOverflow, but the solutions were in Twitter Bootstrap 3 or Bootstrap 4 (using push/pull classes). Some answers say that in Bootstrap 5.0, we use -order for problems like this. But I tried and failed, I don’t really understand how the -order works after reading the documents.
So could anyone please help me out with this problem? Thank you very much!
3
Answers
This can be achieved without Bootstrap with grid. I created a sample for you.
https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Grids
Alternatively, you could use Bootstrap’s breakpoints in display utilities, like this:
The easiest way would be to "disable" flexbox on specific breakpoints which will allow the floats to work. This can be done using all Bootstrap 5 classes so there’s no extra CSS…
Floats in Bootstrap 5 demo
Alternately, you can use the new CSS-grid classes in Bootstrap 5. However this requires that you
$enable-cssgrid
with SASS:CSS grid demo
Related: Bootstrap with different order on mobile version
You can use css property Order:1; very simple. You can reorder in media queries or if you are using Bootstrap they have classes for it as well.use below link for it
https://javascript.plainenglish.io/bootstrap-5-ordering-columns-and-gutters-a27190695b1f