Utilizing Bootstrap 5 with either a 16 or 24 column grid system minus the need for Sass

I'm looking for assistance in adjusting Bootstrap 5 to have either a 16 or 24 column grid rather than the default 12 columns.

I attempted using Bootstrap Customize but found it to be an older version. I want the flexibility to change the grid from 12 to 16 or more depending on the PSD design requirements.

I am interested in making this adjustment directly within the Bootstrap files, without utilizing Sass/less. Can someone provide guidance on how to edit the grid from 12 to 16?

Answer №1

The key factor here is simply dividing 100% by the number of columns required.

To customize for columns 13 and above, you can create your own classes. For instance, a col-13 class would look like this:

.col-13 {
 width:calc(100% / 13);
}

Keep in mind that responsive behavior may not be supported yet. You can include a media query to adjust widths when necessary (e.g., setting width to 100% when width is less than 768).

If you're using SASS and want a simpler approach, consider a setup like this:

$cols: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16;

@each $col in $cols {
  .col-#{$col} {
    width:calc(100% / 16 * $col);
  }
}

These are all custom solutions. For a more comprehensive and recommended method, refer to the Bootstrap documentation:

https://getbootstrap.com/docs/5.0/layout/grid/#variables

Answer №2

Looking for something specific? Check this out.

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4f2d20203b3c3b3b3a3f1f7e617f6d67617163">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container">
    <h3>24 columns</h3>
    <div class="row text-xs-center">
        <div class="col">
            <div class="row">
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
            </div>
        </div>
        <div class="col-sm-3">
            <div class="row">
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
            </div>
        </div>
        <div class="col-sm-3">
            <div class="row">
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
            </div>
        </div>
        <div class="col-sm-3">
            <div class="row">
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
                <div class="col">x</div>
              <div class="col">x</div>
            </div>
        </div>
    </div>
</div>

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

I am experiencing issues with my bootstrap file not working despite providing the correct file path. The styles are not being applied on my webpage

The file path is provided below <link rel="stylesheet" href="../css/bootstrap.min.css"> I have exhausted all options in an attempt to resolve the issue. The browser console indicates a 404 error (err_abborted) ...

Every file downloaded through the iframe is automatically stored in a designated server folder

Is it possible for my website to have an iframe that enables users to browse the web, and when they click on a download button on any external website, the file can be saved directly to a specific folder on my server instead of their own computer? I'm ...

Position the image, text, and header within a box in uniform alignment

Currently, I am working on a design that includes an image, a header, and some text inside a box. However, I am facing an issue with aligning the header so that it appears above the rest of the text. The layout is not turning out as expected. https://i.ss ...

The browser does not support the display of Spanish special characters

I am working on a website and need to incorporate support for the Spanish language. I have prepared an XML file with both English and Spanish text. The XML file is being read based on the user's selection of language from a dropdown menu. Everything s ...

Styling with a Twist: Django Bootstrap 5 Customization

I've integrated django-bootstrap5 into my Django project using this repository. The documentation suggests adding specific configurations to settings.py for customization: BOOTSTRAP5 = { "css_url": {}, // Custom CSS URL can be added her ...

Adding design elements to HTML 5 components

Are there any potential downsides to applying CSS to the <section>, <header>, <article>, and <footer> elements? I vaguely remember reading somewhere that these elements should not be styled, but I can't seem to locate the sourc ...

What could be causing the issue in replicating the Bootstrap documentation using the JavaScript example?

I am attempting to replicate the example shown in the bootstrap documentation but with a few modifications. Instead of using static HTML tags, I want to use JavaScript to dynamically create the elements. Additionally, I would like to implement a nested lis ...

Tips for transferring a JavaScript variable to a servlet

I have implemented the selectable jquery plugin on my JSP page. I need to pass the selected string as a parameter to a servlet when the form is submitted. $(function() { $("#selectable").selectable({ stop: function() { var result = ...

Wagtail one-page website

Recently, I created a one-page site in static HTML featuring shiny divs that span the height of the screen, along with a smooth scrolling function in the navigation bar. The site was designed to include a mix of plain text, images, and a card-deck. Everyth ...

Unable to Utilize Custom Colors in Tailwind CSS within NextJS

I am currently experimenting with NextJs and Tailwinds CSS for a new project. However, I keep encountering an error when attempting to apply a custom background color: Failed to compile ./styles/globals.css:7:12 Syntax error: /Users/anishkunapareddy/Deskto ...

Exploring the world of jQuery and Ajax to retrieve a full HTML framework

I'm a beginner in jQuery and JavaScript programming. While I've managed to use jQuery for my Ajax calls, I'm facing an issue that has me stumped. When making an Ajax call, I'm trying to return a complete HTML structure, specifically a ...

Save an HTML5 canvas element as a picture using JavaScript and specify the file extension

Is there a way to save an Html5 canvas element as an image file using Javascript? I've tried using the CanvasToImage library, but it doesn't seem to work for this purpose. You can view my current code on JsFiddle. <div id="canvas_container" ...

Unexpected behavior from flexbox layout

So I've been experimenting with Chrome lately. I created a div with display: -webkit-box;. Inside this div, there are 7 other divs all set to -webkit-box-flex: 1;. Oddly enough, the first div is smaller than the rest. Any ideas on why this might be ...

the deactivation of my rollover class is being caused by my float class

With the assistance of a generous contributor on stackoverflow, I was able to overlay different colored CSS boxes onto various images. These boxes could be removed upon mouseover, revealing the images beneath. You can view the code I used on fiddle here. ...

What is the best way to hide my rectangle in HTML?

Just starting out with Wix for my website. I have a block of HTML code that creates a blue rectangle, but I want it to disappear automatically after 30 seconds. What additional code do I need to achieve this effect? Also, is there any unnecessary code I c ...

Utilizing Nesting in Less-CSS: Unleash the Power of Greater Than Sign

When working with LESS-CSS, you can achieve the same result with the following code: .a { .b { font-color:red; } } or you can use the nested selector directly like this: .a .b { font-color:red; } But is there a way to target only direct child ...

Positioning Problems with Popups

I have been facing an issue with the positioning of a popup in my trivia game. Despite trying multiple solutions, I have not been able to achieve consistency. Here is a snippet of the HTML code: <div class="logo"> <img src="css/rio-40.png"/& ...

What is the proper way to add process.env.PORT to the script declarations string within my package.json file?

I am facing an issue while trying to upload my file on Heroku that requires including the PORT specification. Unlike my previous projects, this project consists of only html, js, and css files instead of an index.js file. To run it, I am using "live-server ...

The scrollbar located within a table cell is malfunctioning and unresponsive

In a container with a fixed width of 500px, I have a table that contains a cell with potentially long text. To ensure the long text appears on a single line, I set the white-space: nowrap property. However, this causes the table to adjust its size to accom ...

Modify a specific field in a row of the table and save the updated value in a MySQL database

I have successfully retrieved data from a database and displayed it in a table. Now, my goal is to enable editing of a specific field within a row and save the updated value back into MySQL. Here is the code snippet that includes displaying the data in th ...