Skip to content

Instantly share code, notes, and snippets.

@soderalohastrom
Created June 22, 2014 01:42
Show Gist options
  • Save soderalohastrom/581aff3c60dc877844e7 to your computer and use it in GitHub Desktop.
Save soderalohastrom/581aff3c60dc877844e7 to your computer and use it in GitHub Desktop.
Create a responsive “gallery” of blocks
* {
box-sizing: border-box;
}
body {
background: #222;
}
@mixin rowMachine($numPerRow, $margin) {
width: ((100% - (($numPerRow - 1) * $margin)) / $numPerRow);
&:nth-child(n) {
margin-bottom: $margin;
margin-right: $margin;
}
&:nth-child(#{$numPerRow}n) {
margin-right: 0;
margin-bottom: 0;
}
}
.person {
@include rowMachine(5, 2%);
background: white;
padding: 10px;
float: left;
@media (max-width: 1200px) {
@include rowMachine(4, 2%);
}
@media (max-width: 900px) {
@include rowMachine(3, 4%);
}
img {
max-width: 100%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment