Example

Why this approach?
No extra HTML or images, just pure CSS. It stays behind all content and scales responsively. Perfect for design systems or portfolio sites where subtle details matter.
Step 1: Create the pseudo-element
We’ll use body::before to place the grid behind everything:
body::before {
--grid-lines: rgba(0,0,0,0.05);
--gutter: 2.4rem;
--max-width: 1280px;
content: "";
position: fixed;
top: 0;
left: 50%;
transform: translateX(-50%);
width: min(calc(100% - var(--gutter) * 2), var(--max-width));
height: 100vh;
pointer-events: none;
z-index: -1;
background-image:
linear-gradient(to right, var(--grid-lines) 1px, transparent 1px),
linear-gradient(to right, var(--grid-lines) 1px, transparent 1px),
linear-gradient(to right, var(--grid-lines) 1px, transparent 1px),
linear-gradient(to right, var(--grid-lines) 1px, transparent 1px),
linear-gradient(to right, var(--grid-lines) 1px, transparent 1px);
background-position: 0 0, 25% 0, 50% 0, 75% 0, 100% 0;
background-size: 1px 100%;
background-repeat: no-repeat;
}
Step 2: How it works
position: fixedpins the grid to the viewport.left: 50%andtransform: translateX(-50%)centre the grid.background-imageuses multiple linear gradients as vertical lines.background-positionspreads them evenly across your container.- CSS variables let you tweak colours, gutters, and max width easily.
Step 3: Customise it
- Change
--grid-linescolour or opacity for lighter or bolder lines. - Adjust
--gutteror--max-widthto fit your layout width. - Add more gradient layers if you need more columns.