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

后端 未结 11 1189
無奈伤痛
無奈伤痛 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 07:06

    Define columns by min width based on viewport:

    
        /* Number of Cards by Row based on Viewport */
        @media (min-width: 576px) {
            .card-deck .card {
                min-width: 50.1%; /* 1 Column */
                margin-bottom: 12px;
            }
        }
    
        @media (min-width: 768px) {
            .card-deck .card {
                min-width: 33.4%;  /* 2 Columns */
            }
        }
    
        @media (min-width: 992px) {
            .card-deck .card {
                min-width: 25.1%;  /* 3 Columns */
            }
        }
    
        @media (min-width: 1200px) {
            .card-deck .card {
                min-width: 20.1%;  /* 4 Columns */
            }
        }
    

提交回复
热议问题