I recently inherited a web application that utilizes Bootstrap 3 as its framework with some basic customization applied through the recommended _custom-variables.scss
method. The official SASS port is included as a dependency and imported into the app.scss
file using @import "bootstrap";
after _custom-variables.scss
and _custom-mixins.scss
.
Due to the extensive data displayed, the fluid-width app is not suitable for small screens, so I aim to eliminate or deactivate the -xs-
and -sm-
breakpoints from the CSS. The layout will be optimized for -lg-
and -md-
breakpoints, with -md-
being the narrowest breakpoint.
In the _custom-variables.scss
file, I modified the width of $container-tablet
from:
// Small screen / tablet
$container-tablet: (720px + $grid-gutter-width) !default;
//** For `$screen-sm-min` and up.
$container-sm: $container-tablet !default;
// Medium screen / desktop
$container-desktop: (940px + $grid-gutter-width) !default;
//** For `$screen-md-min` and up.
$container-md: $container-desktop !default;
to:
// Small screen / tablet
$container-tablet: (940px + $grid-gutter-width) !default;
//** For `$screen-sm-min` and up.
$container-sm: $container-tablet !default;
// Medium screen / desktop
$container-desktop: (940px + $grid-gutter-width) !default;
//** For `$screen-md-min` and up.
$container-md: $container-desktop !default;
I also added a min-width: $container-md;
to the parent<div>
containing the entire layout.
This setup requires me to include classes for the unwanted breakpoints on my HTML elements. For instance, the following code maintains a column width of 25%:
<div class="col-xs-3 col-sm-3 col-md-3">
Omitting the smaller breakpoint classes removes the width
property, causing the <div>
to default to a width of 100% when the browser width falls below 992px (the min-width
value of the -md-
breakpoint).
My queries:
- Why is it necessary to specify additional smaller breakpoint classes on my containers? (I'm a bit rusty on my Bootstrap knowledge!)
- Is there a more efficient way to disable/remove the two smaller breakpoints?