Skip to content

Instantly share code, notes, and snippets.

@ScottPolhemus
Last active August 29, 2015 14:01
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 ScottPolhemus/a62ce1c1fbdb491f6256 to your computer and use it in GitHub Desktop.
Save ScottPolhemus/a62ce1c1fbdb491f6256 to your computer and use it in GitHub Desktop.
A collection of SASS mixins.
// 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