mirror of
https://github.com/twbs/bootstrap.git
synced 2024-11-29 11:24:18 +01:00
eabed0edf8
Changes grid and container sizes to `px`, as the viewport pixel size does not depend on the font size. The actual em values were inconsistent with the docs, while the docs were not the same as the comments: * `sm` breakpoint was 34em (544px) not 480px. * `lg` container max-width was 60rem (960px), less gutter than `md`. Changed to 940px, same as Bootstrap 3. * `xl` container max-width was 72.25rem which is 1140px not 1156px. Changed to 1140px matching the comment but not the docs. Addresses #17070 and #17388.
77 lines
2.6 KiB
SCSS
77 lines
2.6 KiB
SCSS
// Breakpoint viewport sizes and media queries.
|
|
//
|
|
// Breakpoints are defined as a map of (name: minimum width), order from small to large:
|
|
//
|
|
// (xs: 0, sm: 544px, md: 768px)
|
|
//
|
|
// The map defined in the `$grid-breakpoints` global variable is used as the `$breakpoints` argument by default.
|
|
|
|
// Name of the next breakpoint, or null for the last breakpoint.
|
|
//
|
|
// >> breakpoint-next(sm)
|
|
// md
|
|
// >> breakpoint-next(sm, (xs: 0, sm: 544px, md: 768px))
|
|
// md
|
|
// >> breakpoint-next(sm, $breakpoint-names: (xs sm md))
|
|
// md
|
|
@function breakpoint-next($name, $breakpoints: $grid-breakpoints, $breakpoint-names: map-keys($breakpoints)) {
|
|
$n: index($breakpoint-names, $name);
|
|
@return if($n < length($breakpoint-names), nth($breakpoint-names, $n + 1), null);
|
|
}
|
|
|
|
// Minimum breakpoint width. Null for the smallest (first) breakpoint.
|
|
//
|
|
// >> breakpoint-min(sm, (xs: 0, sm: 544px, md: 768px))
|
|
// 544px
|
|
@function breakpoint-min($name, $breakpoints: $grid-breakpoints) {
|
|
$min: map-get($breakpoints, $name);
|
|
@return if($min != 0, $min, null);
|
|
}
|
|
|
|
// Maximum breakpoint width. Null for the largest (last) breakpoint.
|
|
// The maximum value is calculated as the minimum of the next one less 0.1.
|
|
//
|
|
// >> breakpoint-max(sm, (xs: 0, sm: 544px, md: 768px))
|
|
// 767px
|
|
@function breakpoint-max($name, $breakpoints: $grid-breakpoints) {
|
|
$next: breakpoint-next($name, $breakpoints);
|
|
@return if($next, breakpoint-min($next, $breakpoints) - 1px, null);
|
|
}
|
|
|
|
// Media of at least the minimum breakpoint width. No query for the smallest breakpoint.
|
|
// Makes the @content apply to the given breakpoint and wider.
|
|
@mixin media-breakpoint-up($name, $breakpoints: $grid-breakpoints) {
|
|
$min: breakpoint-min($name, $breakpoints);
|
|
@if $min {
|
|
@media (min-width: $min) {
|
|
@content;
|
|
}
|
|
} @else {
|
|
@content;
|
|
}
|
|
}
|
|
|
|
// Media of at most the maximum breakpoint width. No query for the largest breakpoint.
|
|
// Makes the @content apply to the given breakpoint and narrower.
|
|
@mixin media-breakpoint-down($name, $breakpoints: $grid-breakpoints) {
|
|
$max: breakpoint-max($name, $breakpoints);
|
|
@if $max {
|
|
@media (max-width: $max) {
|
|
@content;
|
|
}
|
|
} @else {
|
|
@content;
|
|
}
|
|
}
|
|
|
|
// Media between the breakpoint's minimum and maximum widths.
|
|
// No minimum for the smallest breakpoint, and no maximum for the largest one.
|
|
// Makes the @content apply only to the given breakpoint, not viewports any wider or narrower.
|
|
@mixin media-breakpoint-only($name, $breakpoints: $grid-breakpoints) {
|
|
@include media-breakpoint-up($name, $breakpoints) {
|
|
@include media-breakpoint-down($name, $breakpoints) {
|
|
@content;
|
|
}
|
|
}
|
|
}
|