Flexbox: 4 items per row

前端 未结 9 1076
南笙
南笙 2020-11-22 13:01

I\'m using a flex box to display 8 items that will dynamically resize with my page. How do I force it to split the items into two rows? (4 per row)?

Here is a releva

9条回答
  •  情话喂你
    2020-11-22 13:10

    I believe this example is more barebones and easier to understand then @dowomenfart.

    .child {
        display: inline-block;
        margin: 0 1em;
        flex-grow: 1;
        width: calc(25% - 2em);
    }
    

    This accomplishes the same width calculations while cutting straight to the meat. The math is way easier and em is the new standard due to its scalability and mobile-friendliness.

提交回复
热议问题