Skip to content

Instantly share code, notes, and snippets.

@Undistraction
Created July 18, 2014 07:17
Show Gist options
  • Save Undistraction/020710bdd03291a1e3b2 to your computer and use it in GitHub Desktop.
Save Undistraction/020710bdd03291a1e3b2 to your computer and use it in GitHub Desktop.
Playing WIth Maps
$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