Firefox has implemented gap
for flexbox layout, while other browsers such as Chrome only support gap
for grid layout. This causes differences between browsers if you add gap
on a flexbox container. The CSS @supports
feature was made to handle situations where browsers do not yet support certain features. So how do you test for support of gap
in flexbox?
<style>
.flex {
display: flex;
gap: 20px;
}
</style>
<section class="flex">
<div>Item One</div>
<div>Item Two</div>
</section>
Please note: Even if I use @supports grid-gap
instead of gap
, Firefox will still apply the gap to the flexbox container, while Chrome won't apply anything, so that solution won't work.
I am looking for consistency, as this is going to be a huge problem going forward if we start applying gaps to flexbox containers, and it works in newer implementations by browsers, but not in older implementations of the spec with no way of testing for support.
I am NOT looking for a JavaScript solution.
margin
instead - see some exampleshere
,here
andhere
– Minta