Home > Web Front-end > CSS Tutorial > 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?

Linda Hamilton
Release: 2024-12-03 22:54:12
Original
247 people have browsed it

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>
Copy after login
  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>
Copy after login
Copy after login
  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>
Copy after login
Copy after login

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

The above is the detailed content of How to Stack Bootstrap 4 Divs on Mobile and Arrange Them Side-by-Side on Desktop?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template