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

后端 未结 11 1186
無奈伤痛
無奈伤痛 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条回答
  •  清歌不尽
    2020-11-28 06:56

    I've used CSS Grid to fix that. CSS Grid will make all the elements in the same row, all the same height.

    I haven't looked into making all the elements in all the rows the same height though.

    Anyway, here's how it can be done:

    HTML:

    ...
    ...

    CSS:

    .grid-container {
      display: grid;  
      grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    

    Here's a complete JSFiddle. https://jsfiddle.net/bluegrounds/owjvhstq/4/

提交回复
热议问题