Flex-box: Align last row to grid

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

    This problem was solved for me using CSS grid,

    This solution is applicable only if you're having fix number of columns i.e. no. of elements to display in a single row

    -> using grid but not specifying number of rows, as number of elements increase it wraps into columns and add rows dynamically, I have specified three columns in this example

    -> you don't have to give any position to your child/cells, as it will make it fix, which we don't want.

    .grid-class{
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      column-gap: 80px;
    }

提交回复
热议问题