Languages

CSS - How to use flexbox with 3 elements per row keeping last elements position?

9 points
Asked by:
elmer
646

I would like to create grid that contains 3 elements per row. I would like to keep elements order even last row have 1 or 2 elements.

Is it possible using only CSS?

1 answer
3 points
Answered by:
Root-ssh
178290

You can use spacer elements that are not visible at the end (add columns_count - 1 spacer elements at the end).

Example solution:

 

Other case:

 

0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join