Skip to content

Instantly share code, notes, and snippets.

@envoytravis
Last active August 29, 2015 14:07
Show Gist options
  • Save envoytravis/42b07208f499a2b1477c to your computer and use it in GitHub Desktop.
Save envoytravis/42b07208f499a2b1477c to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v2.0.0)
// ----
@import "sass-list-maps";
@mixin respond-to($name) {
// If the key exists in the map
@if map-has-key($breakpoints, $name) {
// Prints a media query based on the value
@media screen and #{map-inspect(map-get($breakpoints, $name))} {
@content;
}
}
// If the key doesn't exist in the map
@else {
@warn "Unfortunately, no value could be retrieved from `#{$breakpoint}`. "
+ "Please make sure it is defined in `$breakpoints` map.";
}
}
$breakpoints: (
('small', 'max-width: 767px' ),
('medium', 'min-width: 992px' ),
('large', 'max-width: 1200px' )
);
.test {
@include respond-to('small') {
color: red;
}
}
@media screen and (max-width: 767px) {
.test {
color: red; } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment