Languages

Flexbox 2 elements per row - 100% width of the page when each item have 10px of margin and padding

6 points
Asked by:
Savannah
559

How to arrange 2 elements per row using flex? Let's say total elements is 6, so we need to have 3 rows with 2 elements per row.

Each element needs to have margin and padding set to 10px.

1 answer
10 points
Answered by:
JustMike
31190

Solution:

2 comments
Michael_Dias
2y
If you have an even number of rows (try adding a new one), then, the last row will take the whole space. How to prevent that?
Root-ssh
2y
@ Michael_Dias, try this solution: https://dirask.com/questions/CSS-How-to-use-flexbox-with-3-elements-per-row-keeping-last-elements-position-pr6Ymp
Add 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