Auto-layout malfunctions when .col contains a child .table-responsive

Utilizing Bootstrap's auto-layout grid allows for the explicit specification of width for select columns, with the remaining columns evenly splitting the space. However, when an auto-.col contains a child with .table-responsive, the system appears to malfunction:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<div class="container">
  <div class="row">
    <div class="col" style="height:40px;border: thick solid red">
      Row 1: auto-layout .col operates correctly
    </div>
    <div class="col col-3" style="height:40px;border: thick solid green">
      .col .col-3
    </div>
  </div>
  <div class="row">
    <div class="col" style="height:120px;border: thick solid red">
      Row 2: auto-layout .col > .table-responsive = grid breakdown
      <div class="table-responsive">
        <table class="table">
          <thead>
            <tr>
              <th style="min-width:400px">foobarbazbarfoo</th>
              <th style="min-width:400px">foobarbazbarfoo</th>
              <th style="min-width:400px">foobarbazbarfoo</th>
              <th style="min-width:400px">foobarbazbarfoo</th>
            </tr>
          </thead>
        </table>
      </div>
    </div>
    <div class="col col-3" style="height:120px;border: thick solid green">
      .col .col-3
    </div>
  </div>
</div>

Is there a way to include a .table-responsive child in Bootstrap's grid without specifying explicit width, ensuring consistent behavior? Put simply, how can I make both rows look identical in this scenario - without a vertical break after the table.

Answer №1

To fix the broken grid in your table-responsive section, add overflow: auto to the parent div.

<div class="col" style="height:120px;border: thick solid red; overflow-x:auto">
      Row 2: auto-layout .col > .table-responsive = broken grid

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<div class="container">
  <div class="row">
    <div class="col" style="height:40px;border: thick solid red">
      Row 1: auto-layout .col works fine
    </div>
    <div class="col col-3" style="height:40px;border: thick solid green">
      .col .col-3
    </div>
  </div>
  <div class="row">
    <div class="col" style="height:120px;border: thick solid red; overflow:auto">
      Row 2: auto-layout .col > .table-responsive = broken grid
      <div class="table-responsive">
        <table class="table">
          <thead>
            <tr>
              <th style="min-width:400px">foobarbazbarfoo</th>
              <th style="min-width:400px">foobarbazbarfoo</th>
              <th style="min-width:400px">foobarbazbarfoo</th>
              <th style="min-width:400px">foobarbazbarfoo</th>
            </tr>
          </thead>
        </table>
      </div>
    </div>
    <div class="col col-3" style="height:120px;border: thick solid green">
      .col .col-3
    </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

Struggling to access the height attribute from a CSS file

Hey there. I'm pretty confident that the solution to my query is quite simple. So, I have a .css file with this particular code snippet: div.site { text-align:center; border:2px solid #4b6c9e; padding:1px; margin-top:10px; font-size:medi ...

populate a bootstrap column with numerous span elements containing varying numbers on different rows

Wondering if it's possible to have a div with the bootstrap class "column" filled with multiple span elements that may break into more than one line. The challenge lies in making sure that each line of spans stretches and fills the line, even if there ...

Although my header remains stationary, my body content flows smoothly as I scroll

After applying a high z-index to the header, it appears beautifully, but unfortunately, none of the links in other divs are clickable. I seem to be missing something obvious, yet can't pinpoint the issue. Any assistance would be greatly appreciated! ...

jquery-ui allowing to resize child divisions as well

Currently, I am in the process of developing a website that includes resizable divs with jQuery. However, I have encountered an issue where only the width of the child divs is being resized when I adjust them. For reference, you can view the site and its c ...

How about: "Adding a header to an HTML hyperlink?"

Greetings all, I am a beginner in front-end development and .net MVC. Lately, I have been working on creating a login system for a website and encountered an issue when trying to create links to other pages. For instance, let's say there are two pag ...

Adjustable height for Material UI tab components

I encountered an issue that I initially thought was related to the general configuration of my app and the height I assigned to my page wrapping classes. However, after creating a simple out-of-the-box material UI tab example, it became clear that this beh ...

how to obtain the lineHeight property in UITextView

I am trying to calculate the line height in UITextView for my app. I have used the sizeWithFont:constrainedToSize:lineBreakMode: method, but it seems to give me the height of all lines in the textview. I heard about the Three20 library, but I am not sure h ...

How can I showcase an image using Angular?

Recently, I've started working with Angular and I'm trying to display images using assets. I have a service that looks like this: const IMAGES = [ {"id":1, "category": "boats", "caption": "View from the boat", "url":"assets/img/boat_01.jpeg"}, ...

Dynamic Loading of CSS Styles

My style-sheet is saved in this unique location: /opt/lampp/htdocs/project/core/styles/Style.css To load the CSS file using the full directory, considering that the files utilizing it are situated here: /opt/lampp/htdocs/project/client/ The ultimate ob ...

``There seems to be an issue with the functionality of the href link

Currently, I am utilizing purecss to design colorful buttons on my website. However, I am encountering an issue where the href link is not clickable even though the button displays correctly. <button class='pure-u-1 pure-button pure-button-primary ...

data-icon not displaying correctly in Firefox and Chrome browsers

Can anyone explain why this code works in Safari, but not in Firefox and Chrome? Here is the HTML: <input type="search" placeholder="Search" id="search" name="search" id="s" data-icon="s"> And here is the CSS: #search[data-icon]:before { font ...

Deactivating controls while displaying the loading bar in AngularJS

I'm currently working on a web application using AngularJS. I want to incorporate a loading bar to signify long data load times from the server. To replicate heavy data loads, I am utilizing $timeout to trigger the loadbar when the operation begins a ...

Utilizing a haml document

Looking to view a haml file from a Rails app in the browser. How can this be achieved? I have already initiated rails s and accessed it through http://localhost:3000 But how can I view the haml file alone? ...

Utilizing diverse values retrieved from HTML data attributes

*UPDATE Within my HTML, I have a list titled "#wordlist" that contains the words for my game, along with corresponding audio and images for each word. Everything is functioning correctly. As there will be multiple versions of the game, I've been tas ...

Using JavaScript and jQuery to create a delay when handling input events

I am working on a project where I have an HTML table that retrieves its values from a database using jQuery Ajax. Here is an example: <div id="tableId"></div> Below is the JavaScript code: function showUser(rowsToShow) { request = $.get("s ...

Switching the ASP.NET XHTML Display Mode

I have been given HTML code from a designer to create a master page. The doctype in the HTML is set to HTML 4.0 Strict. The meta tags in the HTML do not contain closing end tags (they end with > instead of />) and the HTML is compliant when checked ...

What is the best way to update JSON data using JQuery?

I apologize for posing a seemingly simple query, but my understanding of JavaScript and JQuery is still in its early stages. The predicament I currently face involves retrieving JSON data from an external server where the information undergoes frequent ch ...

Adjusting the transparency of numerous elements using JavaScript or jQuery

My task involves creating a large form where elements initially have an opacity of 0.5, and when a button is clicked, the opacity changes to 1.0. While I can achieve this using JavaScript, I want to find a more efficient way by avoiding individual if state ...

Arranging nested divs in relation to one another in a specific position

This code represents a chart in HTML. The goal is to have the second (middle) div start where the first (top) div ends, which has a width of 75px. To achieve this, the margin-left for the middle div is set to 75px in the following styles. Following the sam ...

Update the message displayed in MUI DataTables when there are no matching records found

Whenever the data array in my MUIDataTable is empty, a default message pops up stating: "Sorry, no matching records found". I'm looking to personalize this message and input my own text. Any assistance would be greatly appreciated. ...