Skip to content

Instantly share code, notes, and snippets.

@kaspar-allenbach
Created January 24, 2018 10:56
Show Gist options
  • Save kaspar-allenbach/1d8386e01078e495747f5d1fac843637 to your computer and use it in GitHub Desktop.
Save kaspar-allenbach/1d8386e01078e495747f5d1fac843637 to your computer and use it in GitHub Desktop.
GRID CSS Basics
.parentElement {
display: grid; // yeah okay
grid-template-columns: repeat(12, 1fr); // make 12 columns with 1 fraction each
//alt: grid-template-columns: 3fr 1fr 1fr 1fr 3fr; // make a column 3fr wide at the beginning and end (px % vw allowed)
grid-auto-rows: minmax(5vh, auto); // make each row min 5vh in height otherwise apply autogrow
grid-gap: 20px; // add grid
}
.childItem {
grid-column: 2/6; // .childItem runs from axis 2 to axis 6
@include smDown {
grid-column: 4; // on small devices, make .childItem just 4 columns wide starting at axis 1 (just the very left by default)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment