Created
March 20, 2016 02:49
-
-
Save cloudrain21/7b93365c7aa8c841676e to your computer and use it in GitHub Desktop.
sass mixins for image grid
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
$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