Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions scss/_containers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@

@if $enable-grid-classes {
// Single container class with breakpoint max-widths
.container {
@include make-container();
@include make-container-max-widths();
}

.container,
// 100% wide container at all breakpoints
.container-fluid {
@include make-container();
}

// Responsive containers that are 100% wide until a breakpoint
@each $breakpoint, $container-max-width in $container-max-widths {
// Avoid gaps for length differences
$start: if(length($grid-breakpoints) > length($container-max-widths), 1, 0);

@for $i from 1 through length($container-max-widths) {
$breakpoint: nth(nth($container-max-widths, $i), 1);
$container-max-width: nth(nth($container-max-widths, $i), 2);

.container-#{$breakpoint} {
@extend .container-fluid;
}
Expand All @@ -25,18 +26,18 @@
max-width: $container-max-width;
}

// Extend each breakpoint which is smaller or equal to the current breakpoint
$extend-breakpoint: true;
.container {
@extend %responsive-container-#{$breakpoint};
}

@each $name, $width in $grid-breakpoints {
@if ($extend-breakpoint) {
.container#{breakpoint-infix($name, $grid-breakpoints)} {
@extend %responsive-container-#{$breakpoint};
}
@if ($i != length($container-max-widths)) {
@for $j from $start + $i through length($grid-breakpoints) - 1 {
$name: nth(nth($grid-breakpoints, $j), 1);

// Once the current breakpoint is reached, stop extending
@if ($breakpoint == $name) {
$extend-breakpoint: false;
@if map-get($container-max-widths, $name) {
.container-#{$name} {
@extend %responsive-container-#{$breakpoint};
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ $grid-breakpoints: (

// scss-docs-start container-max-widths
$container-max-widths: (
xs: 440px,
sm: 540px,
md: 720px,
lg: 960px,
Expand Down
10 changes: 0 additions & 10 deletions scss/mixins/_container.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,3 @@
margin-right: auto;
margin-left: auto;
}


// For each breakpoint, define the maximum width of the container in a media query
@mixin make-container-max-widths($max-widths: $container-max-widths, $breakpoints: $grid-breakpoints) {
@each $breakpoint, $container-max-width in $max-widths {
@include media-breakpoint-up($breakpoint, $breakpoints) {
max-width: $container-max-width;
}
}
}