Created
March 29, 2012 08:49
-
-
Save simmo/2235117 to your computer and use it in GitHub Desktop.
SASS: Using @content (3.2) - responding to devices
This file contains hidden or 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
@mixin respond_to($device) { | |
@if $device == handheld { | |
@media only screen and (max-width: 767px) { | |
@content | |
} | |
} @else if $device == handheld-landscape { | |
@media only screen and (max-width: 767px) and (orientation: landscape) { | |
@content | |
} | |
} @else if $device == handheld-portrait { | |
@media only screen and (max-width: 767px) and (orientation: portrait) { | |
@content | |
} | |
} @else if $device == tablet { | |
@media only screen and (min-width: 768px) and (max-width: 980px) { | |
@content | |
} | |
} @else if $device == tablet-landscape { | |
@media only screen and (min-width: 768px) and (max-width: 980px) and (orientation: landscape) { | |
@content | |
} | |
} @else if $device == tablet-portrait { | |
@media only screen and (min-width: 768px) and (max-width: 980px) and (orientation: portrait) { | |
@content | |
} | |
} @else if $device == large { | |
@media only screen and (min-width: 1210px) { | |
@content | |
} | |
} | |
} | |
// USAGE | |
body { | |
background: #fff; | |
} | |
@include respond_to(large) { | |
body { | |
background: green; | |
} | |
} | |
@include respond_to(tablet) { | |
body { | |
background: orange; | |
} | |
} | |
@include respond_to(handheld) { | |
body { | |
background: red; | |
} | |
} |
Oops! forgot to upgrade to Sass 3.2, disregard :P
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was previously using this approach, however it no longer seems to work with compass 12.1