Skip to content

Instantly share code, notes, and snippets.

@joshbroton
Created August 20, 2014 17:35
Show Gist options
  • Save joshbroton/5eaac71e02d670afafd8 to your computer and use it in GitHub Desktop.
Save joshbroton/5eaac71e02d670afafd8 to your computer and use it in GitHub Desktop.
Media Queries in a Mixin
.element {
background: red;
@include medium() {
background: blue;
}
@include wide() {
background: red;
}
@include retina() {
background: yellow;
}
}
//--------------------
@mixin medium() {
@media only screen and (min-width: 30em) {
@content;
}
}
@mixin wide() {
@media only screen and (min-width: 50em) {
@content;
}
}
@mixin retina() {
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min--moz-device-pixel-ratio: 2),
only screen and (-o-min-device-pixel-ratio: 2/1),
only screen and (min-device-pixel-ratio: 2),
only screen and (min-resolution: 192dpi),
only screen and (min-resolution: 2dppx) {
@content;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment