How to fix unexpected column order in bootstrap 4?

前端 未结 1 1860
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 15:19

I\'m trying to make a layout like the following:

On xs devices, I\'d like the order to be first-second-third.

The sample code I have is

1条回答
  •  渐次进展
    2020-11-30 16:07

    Bootstrap 4 uses flexbox, so the columns are always going to be equal height, and you'll not be able to get the layout that you want on larger screens. The solution is to disable the flexbox for sm and up. Use floats so that the 3rd taller column floats to the right. The flexbox order- will work on mobile (xs).

    https://www.codeply.com/go/c31HUTtXra

    Second column (medium)
    First column (short)

    Third column (tall)

    ..
    • d-sm-block disables flexbox on sm an up
    • float-left to float the columns when flexbox is disabled so that the tall columns wraps to the right
    • order-* to get the desired order on mobile

    Related:
    Bootstrap with different order on mobile version
    Empty vertical space between columns in Bootstrap 4

    0 讨论(0)
提交回复
热议问题