Firefox ignores vertical margins on flex items (children of a flexbox) unless explicit height is declared on container

后端 未结 2 818
遥遥无期
遥遥无期 2021-02-14 02:45

I have a responsive percentage based grid created with flexbox using percentage based margins. It plays fine in Chrome and Safari. However Firefox collapses the margins unless a

2条回答
  •  广开言路
    2021-02-14 03:27

    You can give the margin width in percentages and the margin height in vw units. This only works if the flexbox wrapper isn't given a fixed width.

    For example: margin: 0 2% 2vw 0;

    Working example: http://codepen.io/anon/pen/JKGjdB

提交回复
热议问题