Left aligned and centered grid with flexbox

后端 未结 7 2079
半阙折子戏
半阙折子戏 2020-12-30 02:21

I\'d like to implement a responsive grid-like layout using flexbox (without media queries). There can be variable number of elements in the grid. Each item should have fixed

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-30 03:11

    You can't achieve this with flexbox out of the box (at least I didn't manage to do it). You can try with justify-content: center; but this will center all childer and you'll get something like:

    So the only solution I managed to find is to use another parent element and wrap everything in it.

    Please see this CodePen http://codepen.io/justd/pen/rOeMGZ

    I'm sure you'll find something working for you, just try to combine different CSS techniques.

提交回复
热议问题