Skip to content

Instantly share code, notes, and snippets.

@CodeVachon
Created May 15, 2019 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeVachon/48109870fcb640f40960da1b59dcaa69 to your computer and use it in GitHub Desktop.
Save CodeVachon/48109870fcb640f40960da1b59dcaa69 to your computer and use it in GitHub Desktop.
My SCSS respondTo media query mixin
.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;
}
}
$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