Adding a fresh, spacious breakpoint in Bootstrap 4 with just CSS

I encountered an issue when the extra large Bootsrap 4 max container width, set at 1140px, was not wide enough for my needs. I aim to ensure that my websites look good on large monitors as well, but the bootstrap grid is too narrow. The most straightforward solution would be to override the .container max-width like this:

@media (min-width: 1200px) {
  .container {
     max-width: 1540px;
  }  
}

However, I don't just want to expand the xl max-width. What I desire is to introduce a new comprehensive breakpoint with all of Bootstrap 4's grid features, including columns, display modes, spacing, etc. Something similar to introducing col-xxl or another equivalent term. Ultimately, it should appear something like this:

<div class="col-xxl-2 col-xl-3 col-md-4 col-sm-6 text-xxl-center"></div>

Do you have any suggestions on how to accomplish this effectively using CSS?

Answer №1

Fortunately, I have developed a solution for your specific request in some of my previous projects. I encountered a similar issue and created a small CSS extension to address it.

To implement this solution, simply create a bootstrap-grid-xxl.css file, or incorporate the code into any existing CSS stylesheet. Be sure that the custom CSS is loaded after the original Bootstrap 4 CSS files to override the container max-width property. Below is the code snippet you can use:

/* BS4 Grid XXL breakpoint */

/* adding col-xxl classes */
.col-xxl, .col-xxl-1, .col-xxl-2, ... {position: relative; width: 100%; padding-right: 15px; padding-left: 15px;}

@media (min-width: 1570px){
    /* expanding BS4 max-width */
    .container {max-width: 1540px;}

    /* define grid columns xxl */
    .col-xxl, .col-xxl-auto, .col-xxl-1, ... {flex-grow: 1; flex-basis: 0; max-width: 100%;}

    /* include other styling rules for different elements based on xxl breakpoint */

}

Alternatively, you can explore incorporating this functionality using Sass if you are familiar with Bootstrap 4 Sass structure. Adapting the principles used in the provided CSS snippet should help you add an XXL breakpoint successfully.

Answer №2

Integrate SASS into your project and include a file named custom.scss (you have the freedom to choose any name you prefer).

Next, add:

$grid-breakpoints: (
        xs: 0,
        sm: 576px,
        md: 768px,
        lg: 992px,
        xl: 1200px,
        xxl: 1600px
);

@import "~bootstrap/scss/bootstrap";

You can now utilize xxl in Bootstrap's mixins. However, if you wish to use col-xxl-*, you must compile custom.scss using node-sass and utilize this compiled bootstrap file as your current bootstrap file.

Find more information at: https://getbootstrap.com/docs/4.4/layout/grid/#grid-tiers

AN ALTERNATE METHOD

Visit the website below to create your breakpoints, then download the customized result:

Answer №3

None of the solutions provided worked for me, so I took matters into my own hands and created a custom gist based on Bootstrap 4.6.0.

The custom code included in the gist modifies the default .container size to 1600px but can easily be adjusted by commenting out specific blocks as needed.

// Customized from bootstrap 4.6.0

/* Styles for Extra Large Screens */
.container-xxl {
  width: 100%;
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

@media (min-width: 1600px) {
  /* Adjusting container sizes for xxl screens */
  .container, .container-sm, .container-md, .container-lg, .container-xl, .container-xxl {
    max-width: 1520px;
  }

  /* Additional styling for flexible column layouts */

  .col-xxl-1, .col-xxl-2, ... // More styles found in the gist link
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with backdrop-filter blur effect not functioning correctly

I'm currently utilizing SCSS and within my _header.scss file, I am importing it into my main.scss like so: @use "header"; Here is the snippet of code from my header file (I've removed some less important details such as borders, margin ...

When the container size increases, elements may overflow and be pushed outside the boundaries

After adjusting the CSS in ".container" from "width:800px" to "width:1900px", all the elements become misaligned. The orange box is no longer centered and instead leans towards the left side. I'm curious if anyone knows why this is happening? A friend ...

Can you place more than one Twitter Bootstrap carousel on a single webpage?

Latest Version of Twitter Bootstrap: 2.0.3 Sample HTML Code: <!DOCTYPE html> <html dir="ltr" lang="en-US" xmlns:og="http://opengraphprotocol.org/schema/"> <head> <link rel="stylesheet" type="text/css" media="all" href="reddlec/style. ...

Adjusting element placement on collapsed navbar using Bootstrap

I've been developing a navbar for a webpage and have successfully aligned the data left and right with the Brand in the center. However, when the navbar collapses, the alignment shifts to Left (over) Brand (over) Right. I want the Brand to remain at t ...

Establishing a boundary by incorporating a variable into a numerical value

Is there a way to adjust the margin-bottom of an element based on the height of the next() element plus 12px? I attempted the code below but it didn't yield the desired results. $("div.entry-content").css("margin-bottom", $(this).next().outerHeight() ...

What could be the reason for the d-flex class in bootstraps preventing my div from expanding to 100% width?

I have a div where I need to display two elements next to each other: a search input field and the corresponding submit button. My attempt so far was to achieve this using the following code: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn. ...

Changing the class of a <div> element with PHP

Is it possible to modify a class using PHP? <div class="divcss red-bg"> to <div class="divecss blue-bg"> I am looking to make this change through a config file so that the div-backgrounds can be altered on all pages without the need for add ...

The height of the container is not adjusted correctly after loading data via ajax which causes it to overlap with

My HTML code consists of a container with two columns (content and sidebar) and a footer. The content contains a horizontal list with li elements that are populated via ajax when the "Load More" button is pressed. I am using Bootstrap and testing on Chrome ...

Javascript function fails to run smoothly during rapidscrolling

I'm facing an issue with my JavaScript code that adjusts the transparency of the navigation bar while scrolling. It works perfectly when scrolling slowly, but when the scrolling speed is fast, it seems like the function is not triggered and the navbar ...

Is there a way to eliminate the directional tag from the base css by utilizing a separate css file?

css, body, forms { text-align: right; } I need to remove this part of the code because it is causing alignment issues with my slider in IE7. ...

Using flexbox to evenly distribute images with borders and padding to ensure consistent height

Currently, I am utilizing jQuery to adjust the flex-grow value of a wrapper div based on the aspect ratio of a figure's image. This approach was suggested here. However, once I apply a border and padding to the figure, the images no longer retain the ...

Ways to turn off the adaptive transient feature

Is there a way to turn off the responsive features and grid layout of Bootstrap? While creating a website for a company, I ensured that it was responsive for mobile devices. However, the company now wants a different design specifically for mobile, with t ...

What is the best way to incorporate the <input> tag within an additional div in a bootstrap 4 form displayed inline?

Picture this straightforward form: <div class="d-flex justify-content-center" style="direction: ltr"> <form class="form-inline flex-fill"> <div class="input-group input-group-lg flex-fill mx-3"> ...

Utilize/Absolve/Add a Prefix to angular material scss styles

Issue I am facing a challenge with integrating angular material SCSS into my application. I want to ensure that these styles are isolated and scoped specifically for my application, as it will be embedded within a larger monolith. The goal is to prevent a ...

How can I adjust the size and alignment of each line within a single cell in an HTML table?

<!DOCTYPE html> <html> <head> <title></title> <meta charset="UTF-8"> <style> .chess-board { border-spacing: 0; border-collapse: collapse; } .chess-board ...

Dealing with a large amount of HTML content following an Ajax request: best practices

I'm currently using a method that works fine, but I can't stop thinking about whether there might be a better way to achieve the same result. The task at hand is to display a user profile in a modal box. When a user clicks on a button or link, a ...

Issue with borders not displaying on cards in Bootstrap 3.4.0

In the 3.4.0 version of Bootstrap, I am facing an issue where cards are not showing borders. I am attempting to include multiple cards within a panel. I have tried using the "!important" property for the border, as well as using classes like "border-prima ...

jQ identifying children with particular styling attributes

I am attempting to locate a child element that meets the following conditions: CSS visibility set to visible and CSS class assigned as foo There will always be only one element that meets these criteria at any given time var visibleBox = $('#parentE ...

Delay loading background image until a specific time has passed, preventing website from fully loading

My website features a vibrant backgroundImage Slideshow that functions seamlessly. However, I am looking to reload the images of the slideshow after a specific time interval. The issue is that the website keeps loading endlessly. Once the website has com ...

Tips for resizing user-uploaded images to fit the required dimensions outlined in the design draft using CSS or JavaScript

Hey everyone! I'm facing an issue but my English isn't great. I'll do my best to explain it thoroughly, and if anything is unclear, please feel free to let me know! So here's the problem: today there's a block for users to upload p ...