Flex-box: Align last row to grid

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

    you want to align

    use align-content: flex-start; instead of justify-content: space-between;

    this pulls the items last row to left , and also distributes space evenly,

    .container {
      display: flex;
      flex-flow: row wrap;
      align-content: flex-start;
      /*justify-content: space-between; remove this line!!!! */ 
    }
    

    https://codepen.io/anon/pen/aQggBW?editors=1100


    danAnderson solution is NOT DYNAMIC .PERİOD!!

    when item width changed from 25 to 28 dan anderson fails space between images

    danAnderson: https://codepen.io/anon/pen/ZwYPmB?editors=1100

    dynamic: https://codepen.io/anon/pen/aQggBW?editors=1100

    thats what ive been trying to say . dans is hacky.....

提交回复
热议问题