-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question regarding media-breakpoint-between #22245
Comments
FYI if breakpoint-max is changed from: @function breakpoint-max($name, $breakpoints: $grid-breakpoints) {
$next: breakpoint-next($name, $breakpoints);
@return if($next, breakpoint-min($next, $breakpoints) - 1px, null);
} To: @function breakpoint-max($name, $breakpoints: $grid-breakpoints) {
@return if($name, breakpoint-min($name, $breakpoints) - 1px, null);
} It works as expected. |
That's not the right fix I think @ksrb; that doesn't snag the next breakpoint at all. I think what we need to do is clear up the nested mixins on the Change I'm suggesting is explicit min and max mapping: // source
@mixin media-breakpoint-between($lower, $upper, $breakpoints: $grid-breakpoints) {
$min: breakpoint-max($lower, $breakpoints);
$max: breakpoint-max($upper, $breakpoints);
@media (min-width: $min) and (max-width: $max) {
@content;
}
}
@mixin media-breakpoint-only($name, $breakpoints: $grid-breakpoints) {
$min: breakpoint-min($name, $breakpoints);
$max: breakpoint-max($name, $breakpoints);
@media (min-width: $min) and (max-width: $max) {
@content;
}
}
// examples
.test {
@include media-breakpoint-between(sm, md) {
background: red;
}
}
.test2 {
@include media-breakpoint-only(sm) {
background: blue;
}
} Which outputs this: @media (min-width: 767px) and (max-width: 991px) {
.test {
background: red;
}
}
@media (min-width: 576px) and (max-width: 767px) {
.test2 {
background: blue;
}
} |
@mdo sorry to come back to this after so many months, so it seems like there was actually a bug. But I was mostly confused about the semantics of the breakpoint functions. $grid-breakpoints: (
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px
) !default; To me But what it does is target the 'next' breakpoints I'm just trying to understand the reason for this, when you see |
I'm also confused of this (using BS 4.1.3):
and it's outputting
I was expecting between 576 and 768. |
I was caught up on this for a second, but it's because the That is from 576 for the start of the sm breakpoint to 991.98, the end of the md breakpoint range. The next breakpoint range for lg starts at 992. |
I was trying out
@media-breakpoint-between
but it doesn't behave the way I expected.Given:
Actual:
Expected:
Example with extracted code in sassmeister.
Respective files:
bootstrap/scss/_variables.scss
Lines 181 to 187 in 78fc4d2
The text was updated successfully, but these errors were encountered: