Skip to content

Instantly share code, notes, and snippets.

@guidobouman
Created October 22, 2012 19:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guidobouman/3933491 to your computer and use it in GitHub Desktop.
Save guidobouman/3933491 to your computer and use it in GitHub Desktop.
Elastic responsive SASS / CSS checkerboard scaling from 2 to 4 blocks wide depending on the container width. The `:nth-child()` calculations are the interesting part.
// Chekkerboard css
#overview
max-width : 1000px
.item
width : 50%
background : white
@media screen and (max-width: 500px)
&:nth-child(4n+2), &:nth-child(4n+3)
background : lightgrey
@media screen and (min-width: 500px) and (max-width: 750px)
#overview
.item
width : 33.33%
&:nth-child(2n)
background : lightgrey
@media screen and (min-width: 750px)
#overview
.item
width : 25%
&:nth-child(8n+2), &:nth-child(8n+4),
&:nth-child(8n+5), &:nth-child(8n+7)
background : lightgrey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment