Could someone explain why Bootstrap columns are positioned in the same row but stacked on top of each other?

In the HTML structure I have provided below, you can see that there is a nested row inside another row, and within that inner row, there are two more columns (trying to split col-9 into more columns).

However, the issue is that instead of appearing next to each other, the inside columns are displayed underneath one another, both acting as if they are col 12 in the row and occupying the entire 100% of that col-9.

(I am attempting to place an input field and a button on the same line)

Thank you in advance

UPDATE: No, haha, I did not forget about the class attributes and their functionality. While typing the code here for the question, I just omitted them. The focus is on the structure of my code. If necessary, I can copy and paste the precise code, but it's quite lengthy.

UPDATE CODE HERE:

<div class="container">
<div class="row">
<!-- ####################################################### NAV BAR ###########################################################-->
    <div class="col col-md-3">
        <ul class="nav nav-pills nav-stacked admin-menu">
            <li class="nav-item"><a class="nav-link active" id="home-tab" data-toggle="tab" onclick="openContent(event, 'home')" role="tab" aria-controls="home" aria-selected="true"><i class="fa fa-home fa-fw"></i>Home</a></li>
            <li class="nav-item"><a class="nav-link active" id="profile-tab" data-toggle="tab" onclick="openContent(event, 'profile')" role="tab" aria-controls="profile" aria-selected="false"><i class="fa fa-list-alt fa-fw"></i>Profile</a></li>
            <?php if ($super_admin == 1) echo '<li class="nav-item"><a class="nav-link active" id="addstaff-tab" data-toggle="tab" onclick="openContent(event, \'add_staff\')" role="tab" aria-controls="add_staff" aria-selected="false"><i class="fa fa-cogs fa-fw"></i>Add Staff Member</a></li>'?>
            <li class="nav-item"><a class="nav-link active" id="settings-tab" data-toggle="tab" onclick="openContent(event, 'settings')" role="tab" aria-controls="settings" aria-selected="false"><i class="fa fa-cogs fa-fw"></i>Settings</a></li>
            <li class="nav-item"><a href="logout.php" data-target-id="Logout"><i class="fa fa-cogs fa-fw"></i>Log Out</a></li>
        </ul>
    </div>
    <!-- END OF NAVBAR -->

    <div class="tab-content col-md-9 well admin-content">
        <!-- ######################################################3################# HOME CONTENT ########################################################################################-->
        <div id="home" class="tab_content">
            <?php echo "<h1>Welcome " . $_SESSION['firstName'] . "!</h1>"?>

            <div class="search">
                <form action="">
                    <input type="text" id="participant" placeholder="Search for participant" onkeyup="showHint(this.value)">
                    
                </form>
                
                <p>Suggestions: <span id="txtHint"></span></p>

                <script>
                    // JavaScript Function
                </script>
                
                <div class="col col-2"></div>
                
                <div class="col col-8 table_div"><table class="table">
                        <?php
                            // PHP Script
                        ?>
                </div>
            </div>
        </div>
        <!-- ######################################################3################# PROFILE CONTENT ########################################################################################-->
        <div id="profile" class="tab_content">
            <h3>Profile</h3>
        </div>
        <!-- ######################################################3################# ADD STAFF CONTENT ########################################################################################-->
        <div id="add_staff" class="tab_content">
            <h3>Add Staff Member</h3>
            <p>Enter Staff ID Number to be added to the System.</p>
            
        </div>
        <!-- ######################################################3################# Settings CONTENT ########################################################################################-->
        <div id="settings" class="tab_content">
            <h3>Settings</h3>
        </div>
    </div>
</div>

Link to Inside Column Image

Link to Inside Row Image

Link to Main Column (col-md-9) Image

Answer №1

Your code is missing the .row class within the content section.

.row and .col are similar to tr and td in tables. Make sure to enclose your .cols with .row

The code is functioning properly, please verify the imported bootstrap files.

.b {
  border: 2px solid blue;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<div class="container">
  <div class="row">
    <div class="col-3 b">3 - Left</div>
    <div class="col-9 b">
      <div class="row">
        <div class="col b">9 - Left</div>
        <div class="col b">9 - Right</div>
      </div>
    </div>
  </div>
</div>

Answer №2

The issue at hand is that you have overlooked the importance of using the class attribute in your HTML elements. Instead of directly assigning classes as attributes, remember to use the correct syntax such as

<div class="col-3"></div>
instead of <div col-3></div>. Without this, Bootstrap's styling won't be applied and your <div> elements will default to stacking vertically, taking up 100% width.

Make sure to include Bootstrap's CSS and JS files by adding the necessary links in your HTML document. An example structure could look like:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<div class="container">
  <div class="row">
    <div class="col-3">3 - Left</div>
    <div class="col-9">
      <div class="row">
        <div class="col-6">9 - Left</div>
        <div class="col-6">9 - Right</div>
      </div>
    </div>
  </div>
</div>

For further guidance, refer to official Bootstrap examples.

Answer №3

Assuming that Obsidian is incorrect and you utilized this 'syntax' as a quick fix, everything appears to be in order. Please share your actual code or review it for any errors.

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

Prevent animation when expanding the menu in Vue using CSS

The animation only works when collapsing the menu, not when expanding it. I tried adding CSS for setting a max-height, but the animation only functions when collapsing the menu. <template> <div> <p> <button @click="is ...

Storing toggle values (on/off) in a PHP database for future reference

I'm trying to use toggle buttons to save responses in a database as 'yes' or 'no'. However, for some reason the only response I am receiving is 'on', even when I switch off the button. I've searched for solutions but ...

How can I apply multiple Tailwind CSS classes to a single element on hover?

Is there a way to combine multiple tailwind css classes in one hover instance on an html element, rather than using separate hover instances? For example, instead of: <button class="hover:bg-blue-900 hover:text-white"></button> is t ...

Is there a way to create a dropdown menu that transforms into a burger icon on smaller screens, while still housing all of my navigation items within it?

I'm currently working on a segment of my header that includes a navbar with 3 links, as well as a dropdown menu listing additional functionalities. Here is the current code I have: <div class="col-md-4 pt-4"> <nav class="navbar ...

Yet another interactive JQuery feature found within the JQuery UI Tabs framework, utilizing seamless Ajax page loading

Currently, I am using JQuery U Tabs with Ajax Page Calls. In my Pages, I have a custom scroller that is functioning correctly. Additionally, I have an ajax search table that works when the page is loaded by itself in the browser but not when called within ...

The issue with the left border color not functioning in JavaScript

Attempting to alter the border-left-color property using this script is resulting in a Uncaught SyntaxError: Unexpected token -. Is border-left-color actually supported? Javascript function logoChange() { var description = new Array (); description[0] ...

Unable to input Email ID and Password within a Selenium Java script for a Bootstrap dropdown menu on the website "https://qa01.pdng.pepsico.com/" without using a frame

To place your Email ID and Password into the appropriate input fields with IDs j_username and j_password, refer to the following HTML code snippet. There are no frames within this code preventing its utilization. ul class="nav__links nav__links--shop_in ...

Is there a way to display x-overflow on a table instead of the window?

Check out the table at the following link: In my CSS, I set a min-width and overflow-x property for the table. However, on the mobile template, the overflow-x does not work properly. I want the template to display correctly with the header and footer in ...

"Implementing jQuery toggle and addClass functions in your

How do I modify the class within the same action as a toggle effect, which works independently very well? (I have multiple blocks with the same classes) $(".w_content").hide(); $(".w_target").click(function() { $(this).parent().next('.w_content&apos ...

The hover and active effects are malfunctioning

I can't understand why the default color for the "a" element is set to #2bb673 instead of #222. What mistake did I make? I am also using Bootstrap. <div class="our-work"> <a href="#our-work" class="our-work">Our Work</a> ...

Mobile devices with a horizontal scroll

Having trouble with side scrolling on mobile devices. I've set two @media queries for tablet and mobile. Visit dev.bdbshop.com @media only screen and (max-width: 767px) { .wrap { max-width: 300px; } Could the issue be related to this? Any suggestio ...

What is the best way to align my clip-path's text with the center of the viewport and ensure that all of the clip-path's text is visible?

Check out my React component demo: https://codesandbox.io/s/epic-brown-osiq1. I am currently utilizing the values of viewBox, getBBox, and getBoundingClientRect() to perform calculations for positioning elements. At the moment, I have hardcoded some values ...

Tips for enhancing the clarity of elements in KineticJS

I'm new to using Kinetic JS, and while I think it's a great library, I'm having trouble with the resolution of the elements. I know that Kinetic JS doesn't use SVG, but the resolution is not up to par. I'm creating circles and othe ...

Utilizing Javascript and HTML5 to upload a .txt file and separate each line into separate input fields

Currently, I am developing an online tool that functions as a database where users can input text data into various fields, save the information in a txt.file, and then retrieve the same data when revisiting the website. I have successfully implemented co ...

The error message indicates that the element countdown is missing or does not exist

I typically refrain from discussing topics that I'm not well-versed in (my weak spot has always been working with time and dates in javascript), but I find myself in urgent need of assistance. I've decided to use this link to showcase a countdow ...

Having trouble retrieving the selected value from a dropdown list with Jquery

In my current setup, I have a drop-down list situated within a pop-up modal. The dropdown menu is structured like this: <select name="EventTypeId" class="form-control formTextBox" id="ddlEventType"> <option value="">Please Select</optio ...

How to remove previous and next buttons in product carousel using Bootstrap 3.3.5

Currently, I am tackling a small project and venturing into the world of bootstrap for the first time. I have hit a roadblock when it comes to disabling (not hiding) product carousel controls when the active state is on the item:first & item:last classes. ...

Explore the search bar with functional filtering for JSON items

I'm currently working on creating a dynamic filter bar integrated with a search functionality. My data is stored in JSON format, including details such as artist name, title, source, and more. Despite successfully retrieving results through console.lo ...

Retrieve data from an Observable containing JSON objects

I am currently working with a Http request that returns Json data, which I then store in an observable. { "proyecto":{ "nombre": "Mercado de Ideas", "tecnologias": [ { "nombre": ".NET", "icono": "http://getsetwebsit ...

What is the best way to delete a table that I created through my programming?

I have utilized the following code to create a table: <html> <head> <title>Table Time</title> </head> <body> <table border="1px"> <tr> ...