Skip to content

Instantly share code, notes, and snippets.

@SmartFinn
Last active January 25, 2017 06:37
Show Gist options
  • Save SmartFinn/a5e2fb407fa5969e91aa6f387afd6d36 to your computer and use it in GitHub Desktop.
Save SmartFinn/a5e2fb407fa5969e91aa6f387afd6d36 to your computer and use it in GitHub Desktop.
SASS Mixins
/// Mixin to prefix several properties at once
/// @author Hugo Giraudel
/// @param {Map} $declarations - Declarations to prefix
/// @param {List} $prefixes (()) - List of prefixes to print
@mixin prefix($declarations, $prefixes: (webkit moz ms o)) {
@each $property, $value in $declarations {
@each $prefix in $prefixes {
#{'-' + $prefix + '-' + $property}: $value;
}
// Output standard non-prefixed declaration
#{$property}: #{$value};
}
}
// Vertical alignment of element within its parent
// -----------------------------------------------
@mixin universal-valign-wrapper($width: 100%, $height: null) {
display: table;
width: $width;
@if ($height) {
height: $height;
}
table-layout: fixed;
}
@mixin universal-valign-content($vert-align: middle) {
display: table-cell;
vertical-align: $vert-align;
}
// Materialize-like Media Query Mixins
// -----------------------------------
$small-screen: 600px !default;
$medium-screen: 992px !default;
$large-screen: 1200px !default;
@mixin small-and-down {
@media only screen and (max-width: #{$small-screen}) {
@content;
}
}
@mixin medium-and-down {
@media only screen and (max-width: #{$medium-screen}) {
@content;
}
}
@mixin medium-only {
@media only screen and (min-width: #{$small-screen + 1px}) and (max-width: #{$medium-screen}) {
@content;
}
}
@mixin medium-and-up {
@media only screen and (min-width: #{$small-screen + 1px}) {
@content;
}
}
@mixin large-and-up {
@media only screen and (min-width: #{$medium-screen + 1px}) {
@content;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment