Last active
June 3, 2024 15:46
-
-
Save signalwerk/6e5b39d5a4ca74393ebde8837bfa37e4 to your computer and use it in GitHub Desktop.
Draw the columns of a grid in the background
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container-grid { | |
--columns: 6; | |
--gap: 1.5rem; | |
position: relative; | |
overflow: hidden; | |
display: grid; | |
grid-template-columns: repeat(var(--columns), 1fr); | |
grid-column-gap: var(--gap); | |
@media only screen and (min-width: 600px) { | |
--columns: 12; | |
} | |
--column-color: rgba(255, 0, 0, 0.07); | |
--transparent: rgba(0, 0, 0, 0); | |
&:before { | |
content: ''; | |
position: absolute; | |
top: 0; | |
left: 0; | |
right: 0; | |
bottom: 0; | |
pointer-events: none; | |
z-index: -1; | |
--column-width: calc( | |
(100% - (var(--columns) - 1) * var(--gap)) / var(--columns) | |
); | |
background-image: repeating-linear-gradient( | |
to right, | |
var(--column-color) 0, | |
var(--column-color) var(--column-width), | |
var(--transparent) var(--column-width), | |
var(--transparent) calc(var(--column-width) + var(--gap)) | |
); | |
background-size: 100% 100%; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment