Skip to content

Instantly share code, notes, and snippets.

@adityadaniel
Created October 5, 2017 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adityadaniel/6c785ee04bade7394bbf817d6090bf8e to your computer and use it in GitHub Desktop.
Save adityadaniel/6c785ee04bade7394bbf817d6090bf8e to your computer and use it in GitHub Desktop.
/* Settings */
:root {
--offset: 1.5rem;
--max_width: 72rem;
--columns: 6;
--gutter: .5rem;
--baseline: 3rem;
--baseline-shift: 2rem;
--color: hsla(204, 80%, 72%, 0.25);
}
@media (min-width: 35em) {
:root {
--offset: 2rem;
--gutter: .75rem;
--color: hsla(286, 51%, 44%, 0.25);
}
}
@media (min-width: 48em) {
:root {
--offset: 3rem;
--columns: 12;
--gutter: 1rem;
--color: hsla(204, 80%, 72%, 0.25);
}
}
@media (min-width: 70em) {
:root {
--offset: 4rem;
--color: hsla(286, 51%, 44%, 0.25);
}
}
/* Helper variables */
:root {
--repeating-width: calc(100% / var(--columns));
--column-width: calc((100% / var(--columns)) - var(--gutter));
--background-width: calc(100% + var(--gutter));
--background-columns: repeating-linear-gradient(
to right,
var(--color),
var(--color) var(--column-width),
transparent var(--column-width),
transparent var(--repeating-width)
);
--background-baseline: repeating-linear-gradient(
to bottom,
var(--color),
var(--color) 1px,
transparent 1px,
transparent var(--baseline)
);
}
html {
position: relative;
}
html::before {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
margin-right: auto;
margin-left: auto;
width: calc(100% - (2 * var(--offset)));
max-width: var(--max_width);
min-height: 100vh;
content: '';
background-image: var(--background-columns), var(--background-baseline);
background-size: var(--background-width) 100%;
background-position: 0 var(--baseline-shift);
z-index: 1000;
pointer-events: none;
}
/* Codepen styling */
body {
height: 400vh;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment