Created
July 18, 2014 07:17
-
-
Save Undistraction/020710bdd03291a1e3b2 to your computer and use it in GitHub Desktop.
Playing WIth Maps
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
$medium-up: 'screen and (min-width: 400px)'; | |
$large-up: 'screen and (min-width: 800px)'; | |
$breakpoints:( | |
medium-up: $medium-up | |
); | |
@mixin responsive-margin($options:()) { | |
@include responsive-property(margin, $options) | |
} | |
@mixin responsive-padding($options:()) { | |
@include responsive-property(padding, $options) | |
} | |
@mixin responsive-property($property, $options:()) { | |
@each $breakpoint, $value in $options { | |
@if $breakpoint == default{ | |
#{$property}: map-get($options, default); | |
} @else { | |
@media #{map-get($breakpoints, $breakpoint)} { | |
#{$property}: $value; | |
} | |
} | |
} | |
} | |
.one | |
{ | |
@include responsive-property(margin, ( | |
default: 10px 20px 50px, | |
medium-up: 5px 10px 25px | |
)); | |
@include responsive-property(padding, ( | |
default: 10px 20px 50px, | |
medium-up: 5px 10px 25px | |
)); | |
} | |
.two | |
{ | |
@include responsive-margin(( | |
default: 10px 20px 50px, | |
medium-up: 5px 10px 25px | |
)); | |
@include responsive-padding(( | |
default: 10px 20px 50px, | |
medium-up: 5px 10px 25px | |
)); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment