Last active
August 29, 2015 14:09
-
-
Save AdmireNL/cc8936bb2f2feff3ad10 to your computer and use it in GitHub Desktop.
Media queries mixin with devices map
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
// ---- | |
// Sass (v3.4.7) | |
// Compass (v1.0.1) | |
// ---- | |
$devices: (tablet: 768px, phone: 320px); | |
@mixin respond-to($device) { | |
@if (map-has-key($devices, $device)) { | |
@media (max-width: map-get($devices, $device)) { | |
@content; | |
} | |
} | |
@else { | |
@warn "Device key not found."; | |
} | |
} | |
h1 { | |
width: 600px; | |
@include respond-to(tablet) { | |
width: 100%; | |
background: red; | |
} | |
@include respond-to(phone) { | |
width: 200px; | |
} | |
} |
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
h1 { | |
width: 600px; | |
} | |
@media (max-width: 768px) { | |
h1 { | |
width: 100%; | |
background: red; | |
} | |
} | |
@media (max-width: 320px) { | |
h1 { | |
width: 200px; | |
} | |
} |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment