Skip to content

Instantly share code, notes, and snippets.

@maxhoffmann
Last active December 25, 2015 17: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 maxhoffmann/7015866 to your computer and use it in GitHub Desktop.
Save maxhoffmann/7015866 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// MIXIN
=when($min: false, $max: false, $ie: false)
@if $min and not($max)
@media (min-width: $min)
@content
@if $max and not($min)
@media (max-width: $max)
@content
@if $min and $max
@media (min-width: $min) and (max-width: $max)
@content
@if $ie
@content
// USAGE
.component
+when($min: 21em)
width: 100%
+when($max: 48em)
padding: 5%
+when($min: 32em, $max: 48em)
font-size: 2em
+when($ie: true)
color: red
.component {
color: red;
}
@media (min-width: 21em) {
.component {
width: 100%;
}
}
@media (max-width: 48em) {
.component {
padding: 5%;
}
}
@media (min-width: 32em) and (max-width: 48em) {
.component {
font-size: 2em;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment