"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Stack Bootstrap 4 Divs on Mobile and Arrange Them Side-by-Side on Desktop?

How to Stack Bootstrap 4 Divs on Mobile and Arrange Them Side-by-Side on Desktop?

Posted on 2025-03-22
Browse:812

How to Stack Bootstrap 4 Divs on Mobile and Arrange Them Side-by-Side on Desktop?

Repositioning divs with Bootstrap 4: Stacked on Mobile, Side-by-Side on Desktop

You want to reorder Bootstrap divs on mobile and place them side-by-side on desktop.

Solution:

  1. Disable Flexbox for Larger Widths:
    Bootstrap 4's flexbox assigns equal heights to columns. To prevent this, disable flexbox for widths larger than medium.
<div>
  1. Use Floats for Smaller Widths (Mobile):
    Enable column floating to allow the second and third columns (B and C) to wrap beneath the first column (A).
        <div>
  1. Assign Column Order:
    Use order- utility classes to reorder the columns on mobile. In this case, set the first column's order to 1 (order-1) and the second column's order to 0 (order-0). This will place A below B on mobile, while maintaining their side-by-side arrangement on desktop.
        <div>

This solution achieves the desired layout, with column A remaining full height and columns B and C stacked beneath on mobile.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3