Last active
January 4, 2019 11:19
-
-
Save ABooooo/8657a1ab65644303d588f14a78e0acd8 to your computer and use it in GitHub Desktop.
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
https://gist.github.com/Metaviolet/682c8d3b05a3a01fd598 | |
//First declare breakpoints | |
$breakpoints: ( | |
'small': 767px, | |
'medium': 992px, | |
'large': 1200px | |
) !default; | |
/// Mixin to manage responsive breakpoints | |
/// @author Hugo Giraudel | |
/// @param {String} $breakpoint - Breakpoint name | |
/// @require $breakpoints | |
@mixin respond-to($breakpoint) { | |
// If the key exists in the map | |
@if map-has-key($breakpoints, $breakpoint) { | |
// Prints a media query based on the value | |
@media (min-width: map-get($breakpoints, $breakpoint)) { | |
@content; | |
} | |
} | |
// If the key doesn't exist in the map | |
@else { | |
@warn "Unfortunately, no value could be retrieved from `#{$breakpoint}`. " | |
+ "Available breakpoints are: #{map-keys($breakpoints)}."; | |
} | |
} | |
//Usage | |
.selector { | |
color: red; | |
@include respond-to('small') { | |
color: blue; | |
} | |
} | |
http://thesassway.com/intermediate/responsive-web-design-in-sass-using-media-queries-in-sass-32 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment