Skip to content

Instantly share code, notes, and snippets.

@RoyalHunt
Created May 12, 2020 14:41
Show Gist options
  • Save RoyalHunt/928d85ab8c8a40b2d92ce099a82f650b to your computer and use it in GitHub Desktop.
Save RoyalHunt/928d85ab8c8a40b2d92ce099a82f650b to your computer and use it in GitHub Desktop.
Visual grid for grid layout
/* Grid */
.grid::before {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
content: '';
pointer-events: none;
--grid-color: rgb(255 0 0 / 0.1);
--grid-sides: 16px;
--grid-gutter: 16px;
--grid-columns: 4;
--grid-column-width: calc(
(100% - var(--grid-gutter) * var(--grid-columns)) / var(--grid-columns)
);
border: solid transparent;
border-width: 0 calc(
var(--grid-sides) - var(--grid-gutter) / 2
);
background-image: repeating-linear-gradient(
to right,
transparent 0,
transparent calc(var(--grid-gutter) / 2),
var(--grid-color) calc(var(--grid-gutter) / 2),
var(--grid-color) calc(var(--grid-column-width) + var(--grid-gutter) / 2),
transparent calc(var(--grid-column-width) + var(--grid-gutter) / 2),
transparent calc(var(--grid-column-width) + var(--grid-gutter))
);
background-repeat: no-repeat;
}
@media (min-width: 736px) {
.grid::before {
--grid-sides: 24px;
--grid-columns: 8;
}
}
@media (min-width: 1008px) {
.grid::before {
--grid-sides: 32px;
--grid-columns: 12;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment