The Inconsistency of Bootstrap 5 Grid with 12-Column Widths

Is it correct to say that a bootstrap grid is made up of 12 columns horizontally (as per the Grid System Documentation])? If I define two columns within a fluid container (always with a width of 100%), the first column as col-md-3, and the second as col-md-9. Why does my second column always end up below the first one instead of being next to it?

        var dataSet = [
            ["Tiger Nixon", "System Architect", "Edinburgh", "5421", "2011/04/25", "$320,800"],
            ["Garrett Winters", "Accountant", "Tokyo", "8422", "2011/07/25", "$170,750"],
            // more data...
        ];

        $(document).ready(function () {
            $('#example').DataTable({
                data: dataSet,
                columns: [
                    { title: "Name" },
                    { title: "Position" },
                    // more columns...
                ]
            });
        });
#newBTN, #updtBTN {
  background: #B3AB7D;
  padding: 10px;
  text-align: center;
  border-radius: 5px;
  color: white;
  font-weight: bold;
  margin: 0 auto;
}
// more css...

</body>
</html>

Answer №1

Don't forget to include a div with the row class right after your container-fluid div. This will ensure correct alignment in Bootstrap when using columns. Remember, wrapping cols within a row class is best practice.

var dataSet = [
   // Data here
];

// DataTable initialization
$(document).ready(function () {
    $('#example').DataTable({
        data: dataSet,
        columns: [
            { title: "Name" },
            { title: "Position" },
            { title: "Office" },
            { title: "Extn." },
            { title: "Start date" },
            { title: "Salary" }
        ]
    });
});
// CSS styles for buttons and legends
.button {
    // Button styles here
}
#newBTN, #updtBTN {
    width: 300px;
}

#my-legend {
    width: 300px;
}
.my-legend .legend-title {
    // Legend title styles
}
.my-legend .legend-scale ul {
    // Legend scale styles
}
.my-legend .legend-source {
    // Legend source styles
}
<!DOCTYPE html>
<html lang="en">
    <head>
        // Head content here
    </head>
    <body>
        <div class="container-fluid">
            <div class="row my-3">
                <div class="col-md-3">
                    // Buttons and legend code here
                </div>
                <div class="col-md-6">
                    <table id="example" class="display" width="100%"></table>
                </div>
            </div>
        </div>
    </body>
</html>

Answer №2

<div class="container-fluid">
    <div class="row">
        <div class="col-md-3" style="background:yellow;">
            LEFT 3 MD | ENTER CODE
        </div>
        <div class="col-md-9" style="background:green;">
            RIGHT 9 MD | ENTER CODE
        </div>
    </div>
</div>

Double check your DIV elements, ensure you have all tags and that the columns are nested inside a row.

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

Organize group data by month in a visually appealing table using HTML/PHP with

I have successfully implemented a code that prints HTML table rows from a database table and sorts them by date. The challenge lies in the fact that the date is stored as VARCHAR (due to a pre-existing project with an active database used in a PHP web app ...

Analyzing Selenium Page Source

Hey there, I've been trying to obtain the full HTML code of my Gmail account page, but have been facing issues with getting it to work properly. Here's what I'm currently getting: https://i.sstatic.net/Ks0sy.png I tried copying these codes ...

Unable to implement the bootstrap panel class as expected

It seems like the bootstrap panel class is not being applied in this code snippet: <div class="container main-content"> <div class="row"> <div class="col-sm-3"> <div class="panel panel-primary"> ...

The Java Selenium "jsExecutor" is unable to click on the HTML element

A JavaScript HTML element is defined as: document.querySelector('[value="fixedsumcredit_kp"]') <input id=​"-0198e3aa-d2b1-46ce-bdf0-192e60662cd3-fixedsumcredit_kp" type=​"radio" name=​"-0198e3aa-d2b1-46 ...

Full height background image

One issue I'm encountering is that the background image randomly disappears when scrolling down, revealing the background color instead. To better illustrate, here's a gif demonstrating the problem: https://gyazo.com/d2d742a1ff1225babe04faa0a597a ...

Steps to create a clickable image input

How can I make an image clickable in an input with type=file? <label for="formFileSm" class="label_display form-label">avatar</label> <input class="width_input mx-auto form-control form-control-sm" id="fo ...

What could be the reason why my JavaScript code for adding a class to hide an image is not functioning properly?

My HTML code looks like this: <div class="container-fluid instructions"> <img src="chick2.png"> <img class="img1" src="dice6.png"> <img class="img2" src="dice6.png" ...

Which is better for cycling through a list of items: CSS or JavaScript?

Currently, I have a navigation bar set up as an unordered list (<ul>), but some list items are not visible. I want to implement functionality where clicking arrows will move the elements left or right by hiding or showing the leftmost or rightmost it ...

Having trouble with button alignment in the header with Bootstrap 3?

Using Bootstrap 3 and looking to adjust the alignment of a star icon with the title in my HTML page. Here is the current setup: <p class="pull-right visible-xs"> <h3><center>2000 Cadillac Eldorado Esc (Prospect heights) $3500 ...

Interact with Datatable by clicking on the table cell or any links within the cell

When I am working with the datatable, I want to be able to determine whether a click inside the table was made on a link or a cell. <td> Here is some text - <a href="mylink.html">mylink</a> </td> Here is how I initialize my da ...

Loss of Image Quality when Zooming out Canvas

I have developed a code to implement zoom-in and zoom-out functionality for a canvas image. However, I am facing an issue where the quality of the image deteriorates when zoomed more than once. I am using the canvas2image plugin to convert the canvas into ...

Is it possible to utilize WebMatrix for hosting a website?

Is it possible to utilize Webmatrix for publishing and editing websites? I am currently using Weebly and getting tired of logging in and out to make changes. Can I edit my website with Webmatrix and publish it directly from there? ...

Tips for preventing child elements from becoming distorted when the parent element is resized

How can I prevent rotated child elements from skewing when the parent element is scaled? Here is the code snippet that I am working with: <svg viewbox="0 0 500 500"> <g class="parent" transform="matrix(1.71341 0 0 1 -42.302 0)"> <path ...

What is the method for activating the on collapse event with a bootstrap navbar?

I am encountering a common issue with collapsing the navbar on smaller screens and triggering an event when the collapse button icon is clicked. Despite my efforts to find a solution, I have been unsuccessful in using the following JavaScript code: $(&apos ...

Change the blue line to a crisp, clean white

Is it possible to customize the color of the blue line that appears when clicked? class Greetings extends React.Component { render() { return <div>Greetings {this.props.name}</div>; } } ReactDOM.render( <div> <p tabInde ...

What is the purpose of calling Array.prototype.filter on the 'forms' array with the function(form)?

I'm struggling to grasp the inner workings of this code snippet. It appears to be a piece of form validation code taken from Bootstrap and pasted here. My confusion arises from this line var validation = Array.prototype.filter.call(forms, function(f ...

Tips for adjusting the size of numbers (e.g. 0, 1,4..) using CSS

I have a paragraph on my website that contains a phone number and an email address within the header section. I have styled them to be the same font-size: small, but for some reason, the phone number appears slightly larger than the email address when view ...

Adjusting the length of the To, CC, and BCC text fields in web design

I'm developing a webpage that will collect email addresses for user notifications. I want to ensure the length limits of the 'to,' 'cc,' and 'bcc' fields. According to RFC 2821/3696, an email address can be up to 256 cha ...

What is causing iframes to fail on some websites?

Recently, while I was experimenting with a jQuery tutorial, I encountered an issue where iframes were not working as expected. Surprisingly, only the iframes from w3schools seemed to work fine, leaving me confused about what could be causing the problem. & ...

Is it possible to achieve efficient Autocompletion features within VS Code?

Just had my first experience with PhpStorm and I must say, I'm impressed, especially with the completion feature. Pressing Ctrl + Space on my Mac gives me relevant suggestions, like when I'm in a JS file and my project includes jQuery, I get Ele ...