Skip to content

Instantly share code, notes, and snippets.

@cloudrain21
Created March 20, 2016 02:49
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 cloudrain21/7b93365c7aa8c841676e to your computer and use it in GitHub Desktop.
Save cloudrain21/7b93365c7aa8c841676e to your computer and use it in GitHub Desktop.
sass mixins for image grid
$roundness: 20px 0 20px 0;
@mixin clearfix {
&:before,
&:after {
content: '';
display: table;
}
&:after {
clear: both;
}
}
@mixin imagegrid($qty, $margin) {
width: ((100% - (($qty - 1) * $margin))/$qty);
&:nth-child(n) {
margin-right: $margin;
margin-bottom: $margin;
}
&:nth-child(#{$qty}n) {
margin-right: 0;
margin-bottom: 0;
}
}
.grid {
@include clearfix;
.item {
float: left;
@include imagegrid(14, 1%);
}
img {
display: block;
border-radius: nth($roundness, 1);
max-width: 100%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment