"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Override Bootstrap 4.x & 5.x Grid System Breakpoints?

How to Override Bootstrap 4.x & 5.x Grid System Breakpoints?

Published on 2024-11-09
Browse:794

How to Override Bootstrap 4.x & 5.x Grid System Breakpoints?

Overriding Bootstrap 4.x & 5.x Grid System Breakpoints

To customize Bootstrap's xl breakpoint, it's crucial to understand the variables that govern breakpoints and container widths.

sass
In your Sass build, you'll need to modify two variables: $grid-breakpoints and $container-max-widths. These variables define the size thresholds at which the Bootstrap grid system and container elements will restructure themselves.

In the provided Sass code, you've correctly adjusted the $grid-breakpoints to include a 1280px breakpoint. However, for the changes to take effect, you must also modify the $container-max-widths variable.

Working Example
To override the xl breakpoint and set it to 1280px, here's a working example in Sass:

// theme.scss
// Override default BT variables
$grid-breakpoints: (
  xs: 0,
  sm: 576px,
  md: 768px,
  lg: 992px,
  xl: 1280px, // Custom xl breakpoint
  xxl: 1900px
);

$container-max-widths: (
  sm: 540px,
  md: 720px,
  lg: 960px,
  xl: 1220px, // Custom max-width for xl breakpoint
  xxl: 1610px
);

// Import BT sources
@import "../node_modules/bootstrap/scss/bootstrap";

// Your CSS (SASS) rules here...

In this example, you've successfully extended Bootstrap's breakpoints to include your custom 1280px breakpoint while also adjusting the container's maximum width accordingly.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3