Created
May 15, 2019 01:28
-
-
Save CodeVachon/48109870fcb640f40960da1b59dcaa69 to your computer and use it in GitHub Desktop.
My SCSS respondTo media query mixin
This file contains 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
.profile .title { | |
font-size: 1.6rem; | |
font-weight: bold; | |
} | |
@media screen and (min-width: 0) and (max-width: 1087px) { | |
.profile .title { | |
font-size: 1.3rem; | |
} | |
} |
This file contains 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
$breakPoints: ( | |
"mobile": ( | |
"min": 0, | |
"max": 699 | |
), | |
"tablet": ( | |
"min": 700, | |
"max": 1023 | |
), | |
"desktop": ( | |
"min": 1024, | |
"max": 1299 | |
), | |
"widescreen": ( | |
"min": 1300, | |
"max": 100000px | |
) | |
); | |
@mixin respondTo($requestedBreakPoints, $media: "screen") { | |
$minValue: false; | |
$maxValue: false; | |
@each $breakPoint in $requestedBreakPoints { | |
$bpData: map-get($breakPoints, $breakPoint); | |
@if (map-has-key($bpData, "min")) { | |
@if ( | |
($minValue == false) or | |
(map-get($bpData, "min") < $minValue) | |
) { | |
$minValue: map-get($bpData, "min"); | |
} | |
} | |
@if (map-has-key($bpData, "max")) { | |
@if ( | |
($maxValue == false) or | |
(map-get($bpData, "max") > $maxValue) | |
) { | |
$maxValue: map-get($bpData, "max"); | |
} | |
} | |
} | |
@media #{$media} and (min-width: $minValue) and (max-width: $maxValue) { | |
@content; | |
} | |
} // close respondTo | |
.profile { | |
.title { | |
font-size: 1.6rem; | |
font-weight: bold; | |
@include respondTo(mobile tablet) { | |
font-size: 1.3rem; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment