Equal height columns with centered content in flexbox

后端 未结 2 1616
时光说笑
时光说笑 2020-12-05 20:04

I\'d like to have two columns of equal height and their content should be middle aligned, so in the very center of each div.

Problem: \'equal height

2条回答
  •  天涯浪人
    2020-12-05 20:27

    You need to give height to your elements

    .height {
      height: 300px;
    }
    .row {
      height: 100%;
    }
    .row > div {
      height: 100%;
    }
    

    Updated fiddle 1

    If you want them to center vertical, update above .row > div rule to this

    .row > div {
      height: 100%;
      display: flex !important;
      flex-direction: column;
      justify-content: center;
    }
    

    Updated fiddle 2

提交回复
热议问题