Menu

1 / 5

CSS gap decorations: lines between grid items

DEV Community: css·richi.codes·18 days ago
#M4ZlM5oi
#devtocss#devto#dev#rule#column
Reading 0:00
15s threshold

This note has an interactive demo. Try it in the original

Drawing a line between grid cells has always been a hack: borders on half the items, :nth-child() rules to remove the extra ones, or a coloured background peeking through the gaps. Since Chrome and Edge 149 there's a real property for it: row-rule and column-rule now work on grid and flex containers, not just on multi-column text.

I like this one because it fixes a very everyday problem. Bento layouts, dashboards, pricing tables, footers with columns: they all want separators, and separators belong to the gap, not to the items.

What gap decorations are

column-rule isn't new. It has drawn the line between columns of multi-column text for years. The CSS Gaps module takes that idea and extends it to grid and flexbox, adds the row direction with row-rule , and gives you control over where lines break, which gaps get a line, and how far the ends are pulled back.

Two rules from the spec are worth knowing before you start:

They take up no space.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.