Flex-box: Align last row to grid

后端 未结 29 2994
不知归路
不知归路 2020-11-22 02:54

I have a simple flex-box layout with a container like:

.grid {
  display: flex;
  flex-flow: row wrap;
  justify-content: space-between;
}

29条回答
  •  庸人自扰
    2020-11-22 03:23

    If you know the width of spaces between elements in the row and the amount of elements in a row, this would work:

    Example: 3 elements in a row, 10px gap between elements

    div:last-child:nth-child(3n+2) {
      flex-grow: 1
      margin-left: 10px
    }
    

提交回复
热议问题