Flex-box: Align last row to grid

后端 未结 29 2516
不知归路
不知归路 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:18

    Add a ::after which autofills the space. No need to pollute your HTML. Here is a codepen showing it: http://codepen.io/DanAndreasson/pen/ZQXLXj

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

提交回复
热议问题