Flexbox Gap Finally Fixed Our Spacing
Gap on flex containers removed a whole class of spacing bugs from our sites.
What we removed
Colour is the last thing we add. Getting the structure right in black and white first saves a lot of arguing later.
- Negative margins on wrappers
- Last-child margin resets
- Spacer divs between buttons
None of this is new. It is the same advice print designers have given for a century, moved onto screens.
Spacing belongs to the parent. Gap finally lets it live there.
We keep a scratch file of small experiments like this one. Most of them go nowhere, but a few end up in every project.
Clients rarely notice these details directly. They notice that the site feels solid, and that nothing jumps around when it loads.
The code is short enough to read in one sitting. That matters, because code you can read is code you can change.
We still get it wrong sometimes. The difference now is that fixing it takes one line instead of an afternoon.
Try it on a small page first, not your whole site. You will learn more from one finished page than a half-finished redesign.
12 thoughts on “Flexbox Gap Finally Fixed Our Spacing”
Clear, short and useful. More like this, please.
It holds up, as long as the gap stays consistent.
Same here. It took a week to get used to it.
We tried that and it worked fine for us.
We tried that and it worked fine for us.
We tried that and it worked fine for us.
I tried this on a client site last week and it cut the stylesheet in half.
Clear, short and useful. More like this, please.
I disagree on the shadows, but the rest is spot on.
Finally someone says it plainly. Thank you.
This is exactly the kind of post that keeps me reading this blog.
Finally someone says it plainly. Thank you.