Last active
August 29, 2015 14:01
-
-
Save ScottPolhemus/a62ce1c1fbdb491f6256 to your computer and use it in GitHub Desktop.
A collection of SASS mixins.
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
// SASS Mixins | |
// ----------- | |
// Force an element to fill its container | |
@mixin fill { | |
position: absolute; | |
top: 0; bottom: 0; | |
left: 0; right: 0; | |
} | |
// Aspect ratio (apply to wrapper) | |
// http://www.mademyday.de/css-height-equals-width-with-pure-css.html | |
@mixin aspect-ratio($w, $h) { | |
position: relative; | |
&:before { | |
content: ""; | |
display: block; | |
padding-top: (100% * $h / $w); | |
} | |
> * { | |
@include fill; | |
} | |
} | |
// Square aspect ratio shorthand | |
@mixin aspect-sq { | |
@include aspect-ratio(1, 1); | |
} | |
// Justify for responsive layout | |
// http://www.barrelny.com/blog/text-align-justify-and-rwd/ | |
@mixin justify { | |
text-align: justify; | |
> * { | |
display: inline-block; | |
vertical-align: top; | |
text-align: left; | |
} | |
&:after{ | |
content: ''; | |
display: inline-block; | |
width: 100%; | |
} | |
} | |
// Combined media queries for width *or* height | |
@mixin min($w, $h: $w) { | |
@media (min-width: $w), (min-height: $h) { | |
@content; | |
} | |
} | |
@mixin max($w, $h: $w) { | |
@media (max-width: $w), (max-height: $h) { | |
@content; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment