CSS - Equal Height Columns?

前端 未结 11 1142
情歌与酒
情歌与酒 2020-11-21 06:08

In CSS, I can do something like this:

But I\'ve no idea how to change that to something like:


Is this possible with CSS?

11条回答
  •  暖寄归人
    2020-11-21 06:56

    Use Flexbox to create equal height columns

    * {box-sizing: border-box;}
    
    /* Style Row */
    .row {
      display: -webkit-flex;
      -webkit-flex-wrap: wrap;
      display: flex;
      flex-wrap: wrap;
    }
    
    /* Make the columns stack on top of each other */
    .row > .column {
      width: 100%;
      padding-right: 15px;
      padding-left: 15px;
    }
    
    /* When Screen width is 400px or more make the columns stack next to each other*/
    @media screen and (min-width: 400px) {
      .row > .column {    
        flex: 0 0 33.3333%;
        max-width: 33.3333%;
      }
    }

    Column 1

    Some Text...

    Some Text...

    Column 2

    Some Text...

    Some Text...

    Some Text...

    Some Text...

    Some Text...

    Some Text...

    Some Text...

    Column 3

    Some Text...

    Some Text...

    Some Text...

提交回复
热议问题