flex-direction: row - children of same height

前端 未结 2 1705
眼角桃花
眼角桃花 2021-01-23 07:44

How is it possible to get the .childs to all have the same height. height: 100% is not working an neither is flex-grow: 1. What is the rec

相关标签:
2条回答
  • 2021-01-23 08:29

    .parent {
        display: flex;
        flex-direction: row;
        width: 800px;
        justify-content: center;
        align-items: stretch;
    }
    
    .child {
      width: 150px;
      background-color: green;
      border: solid 1px black;
    }
    <div class="parent">
      <div class="child">
        Short Text
      </div>
      <div class="child">
        Long Text: Bla bla bla Bla bla bla Bla bla bla Bla bla bla Bla bla bla
      </div>
      <div class="child">
        Short Text
      </div>
    </div>

    0 讨论(0)
  • 2021-01-23 08:50

    Remove the align-items:center from the parent and add flex properties to the children for their content alignment.

    .parent {
        display: flex;
        flex-direction: row;
        justify-content: center;
        width: 800px;
    }
    
    .child {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
      width: 150px;
      background-color: green;
      border: solid 1px black;
    }
    <div class="parent">
      <div class="child">
        Short Text
      </div>
      <div class="child">
        Long Text: Bla bla bla Bla bla bla Bla bla bla Bla bla bla Bla bla bla
      </div>
      <div class="child">
        Short Text
      </div>
    </div>

    0 讨论(0)
提交回复
热议问题