Bootstrap 5: Situation where a table placed in the second column suddenly shifts below the first column

I've set up a grid layout with navigation pills in the left column styled as "col-auto" to only take up the natural width of the content.

However, I'm facing an issue with my large table in the second column. Despite having a horizontal scrollbar, it always jumps below the navigation bar instead of being rendered to the right.

You can see the problem in action in this fiddle: https://jsfiddle.net/3vxhd6jf/3/

<div class="container">
   <div class="row">
     <div class="col-auto"> <!-- Should only take up the necessary space -->
       <!-- Nav tabs -->
       <div class="d-flex align-items-start">
       .....
       </div>
     </div>
     <div class="col"> <!-- Should take up the rest of the space -->
       <div class="tab-content">
         <div class="tab-pane active" id="tab-data" role="tabpanel" aria-labelledby="nav-data">
           <div id="div-data-container" class="mb-3 table-responsive">
             <!-- The table -->
             <table class="table table-sm table-striped">
             .....
             </table>
           </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>    

I'm looking to have the table render to the right of the navigation pills, similar to how the textarea appears when clicking on the 'JSON' pill. Can you assist with this issue?

Answer №1

Bootstrap rows act as flex containers that naturally wrap elements. To keep columns on the same line, you must prevent this wrapping.

To achieve this, add the flex-nowrap class to your row:

<div class="row flex-nowrap">

When all content remains on a single row, you may encounter overflow issues due to table size. To contain the content within the row, use Bootstrap's table-responsive class and apply overflow-hidden to the column containing the table.

<div class="col overflow-hidden"> <!-- insert tab content / table markup here -->

For more information, refer to: https://getbootstrap.com/docs/5.0/utilities/flex/#wrap

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

Image retrieval failed due to unsuccessful HTTP request

After double-checking, it's confirmed that the images do exist on the server. I have embedded the image in a CSS rule using the following code: .Invite{background: url("../images/interface/Shop/Btn_Ad_Invite_all.png") 0px 0px;} .Invite:hover{ backgr ...

Modify the color of every x number of rows on an HTML table

Is it possible to change row colors in a table every x rows, instead of every single row? For example, here is what the alternating rows could look like when changing every 2 rows: JSFiddle The structure of the HTML table would be something similar to th ...

What is the best way to turn off the annoying pop-up messages that show up for input validation, specifically the one that says "Please complete

Currently using Angular 2, my form has input fields similar to this simplified version: <input class="body-text1" type="text" [(ngModel)]="model.name" name="name" required minlength="1"> <!--more inputs like this --> Although I have implement ...

Desktop froze up as modal failed to respond

I recently updated my modal to only work on screens smaller than tablets, which was successful. However, I now need it to also work on desktop size. After trying to change d-none to d-block, it still didn't work. Any suggestions? <div class="col ...

Initially unresponsive: Jquery localStorage not triggering on initial click

Whenever I click on the print-receipt button, my goal is to alter the class of a child div to receipt_finished. After that, I intend to substitute the localStorage item with the updated html content (which now includes the receipt_finished class). Here i ...

What is the reason for the absence of styles in index.html when accessing the local server?

When using node.js to open the server, I encountered an issue where the styles are not displaying. Strangely, when opening index.html directly in the browser, all the styles show up correctly. What could be causing this discrepancy? index.html <!doctyp ...

Utilize a dynamic approach to add the active class to navigation list items

My files all have a header that includes a navigation bar. I am trying to use jQuery to add the 'active' class to the relevant list items (li). The method I initially thought of involved setting a variable on each page, assigning an ID equal to ...

How can I disable a checkbox in AngularJS?

Is there a way to automatically disable a checkbox when selecting an item from the combo box? For example, if "ABONE" is selected, Angular should disable the ABONE checkbox. Note (for example): DefinitionType: ABONE https://i.sstatic.net/vcZpR.png ...

Reposition various div elements within a static container

Struggling to align div boxes like the image below was exhausting: I attempted fixing it with the code provided in this JSBIN link. How can I resolve the issue and adjust the layout as desired? Any help would be greatly appreciated. Thank you in advance ...

activating a button following the selection of a checkbox

My code includes a submit button that is currently disabled. I am looking to enable it when the user clicks on the "I agree" checkbox using jQuery. Can someone assist me with this? My code is written in HTML, JavaScript, and jQuery. <input id="agree" ...

bootstrap for a responsive full-screen background image

I'm new to utilizing Twitter's Bootstrap. I am curious about the HTML layout required for implementing a full-screen responsive background image with Bootstrap. Currently, I am using the following mockup: <div class="container-fluid"> &l ...

What could be causing my background image to vanish or flicker in Bootstrap?

Something unusual is happening with my website. There's a section with a static background image, and as you scroll, a quote and button (which will eventually link to a store) appear on top of it. Previously, this setup was working fine. However, yest ...

Comparing Flexbox Wrapping Behavior in Chrome and Firefox

Hey there! I'm currently grappling with ensuring that this (3-3) flexbox layout appears consistently on both Chrome and Firefox browsers. If you'd like to see a functioning example of what I'm trying to achieve (three columns and two rows) ...

JQuery ID Media Queries: Enhancing responsive design with targeted

Is it possible to integrate a media query into the selection of an ID using JQuery? For example: $('#idname') $('@media (max-width: 767px) { #idname }') In essence, can you target the #idname with that specified media query in JQuery ...

Using bootstrap's center-block class, you can easily center

I'm attempting to center the content of a form. <div class="login-container"> <div class="center-block"> <form action="/joinChart" method="get"> <input name="username" id="username" type="text"><br><br> ...

Modifying the Background Color of a Header in React Native

As a newcomer to React Native, I am attempting to change the background color of the header bar (Navigation Bar). Here are some approaches that I have tried: return ( <View style={styles.container}> <NavigationBar titl ...

What is the best way to utilize the z-index property to ensure that the preceding element covers the one that follows

Is it possible to create an effect where the previous block overlaps the next one using CSS? .container { padding: 70px; width: 500px; margin: auto; display: flex; } .block { margin-left: -30px; width: 200px; height: 100px; border: 1px ...

Customize list items using IDs once they have been generated

My vertical timeline is dynamically generated with <li> elements that have an ::after pseudo-class. I want to style specific circular elements after the timeline creation (only changing the color of the circles). I am struggling to add a class to in ...

Getting rid of the border on a material-ui v4 textbox

I am currently using Material-UI version 4 and have not upgraded to the latest mui v5. I have experimented with various solutions, but so far none have been successful. My goal is simply to eliminate or hide the border around the textfield component. < ...

Click a Bootstrap button to navigate to a different section on the current webpage

My button CTA is not redirecting to the second part of the webpage despite using onclick and <a href:"#" methods. The button is supposed to link to either the About section or the accordionFlushExample id, but nothing seems to trigger a response. Any s ...