Equal height rows in a flex container

前端 未结 9 803
梦如初夏
梦如初夏 2020-11-22 09:28

As you can see, the list-items in the first row have same height. But items in the second row have different height

9条回答
  •  天命终不由人
    2020-11-22 09:52

    you can do it by fixing the height of "P" tag or fixing the height of "list-item".

    I have done by fixing the height of "P"

    and overflow should be hidden.

    .list{
      display: flex;
      flex-wrap: wrap;
      max-width: 500px;
    }
    
    .list-item{
      background-color: #ccc;
      display: flex;
      padding: 0.5em;
      width: 25%;
      margin-right: 1%;
      margin-bottom: 20px;
    }
    .list-content{
      width: 100%;
    }
    p{height:100px;overflow:hidden;}
    • box 1

      Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    • box 2

      Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    • box 2

      Lorem ipsum dolor

    • box 2

      Lorem ipsum dolor

    • h1

提交回复
热议问题