Home > Article > Web Front-end > How to Reorder Bootstrap Columns Differently on Mobile vs. Desktop?
In web development using Bootstrap, there may arise a need to reorder columns differently on mobile devices compared to larger screens. This question explores a scenario where the column order is desired to switch from 1-3-2 on the desktop version to 1-2-3 on the mobile version.
Bootstrap 4 employs flexbox for layout, which typically results in equal heights for columns. This feature poses a challenge in achieving the desktop layout desired in this case. To circumvent this, one approach is to disable flexbox on larger screens (e.g., LG) and utilize floats to enable natural alignment of columns.
Here's an example code that incorporates this approach:
<div>
How it Works:
Another option is to explore flexbox wrapping hacks involving w-auto. However, the solution presented above offers a straightforward means of achieving the desired column order in Bootstrap.
The above is the detailed content of How to Reorder Bootstrap Columns Differently on Mobile vs. Desktop?. For more information, please follow other related articles on the PHP Chinese website!