Bootstrap 4 card-deck with number of columns based on viewport

后端 未结 11 1193
無奈伤痛
無奈伤痛 2020-11-28 06:10

I\'m trying to implement the card-deck feature in bootstrap 4 to make all of my cards the same height.

The examples that bootstrap provides show 4 nice cards, but it

11条回答
  •  旧时难觅i
    2020-11-28 06:58

    Updated 2018

    If you want a responsive card-deck, use the visibility utils to force a wrap every X columns on different viewport width(breakpoints)...

    Bootstrap 4 responsive card-deck (v 4.1)


    Original answer for Bootstrap 4 alpha 2:

    You can use the grid col-*-* to get the different widths (instead of card-deck) and then set equal height to the cols using flexbox.

    .row > div[class*='col-'] {
      display: flex;
      flex:1 0 auto;
    }
    

    http://codeply.com/go/O0KdSG2YX2 (alpha 2)

    The problem is that w/o flexbox enabled the card-deck uses table-cell where it becomes very hard to control the width. As of Bootstrap 4 Alpha 6, flexbox is default so the additional CSS is not required for flexbox, and the h-100 class can be used to make the cards full height: http://www.codeply.com/go/gnOzxd4Spk


    Related question: Bootstrap 4 - Responsive cards in card-columns

提交回复
热议问题