Issue with Bootstrap table in IE11 due to Flex styling

There seems to be an issue with IE11 and Flexbox when using Bootstrap tables.

My table row is set up like this:

https://i.sstatic.net/iLoNS.png

I have a table design that is scrollable to the right due to the numerous fields in it. The flex with column setup helps maintain the column widths.

This functionality works well in Chrome and Firefox, as shown in the image below:

https://i.sstatic.net/5exHB.png

However, in IE, it appears broken as the tbody row is shifted differently compared to the thead row. Both of them have the same structure and classes as shown in the first image.

https://i.sstatic.net/1Al82.png

Any suggestions on how to fix this? I need to support IE11 for this project and it's proving to be a challenge.

UPDATE: Here is the code for the table:

<table class="table-responsive table-sm">
        <thead>
        <tr class="d-flex">
            <th class="col-1">Bla 1</th>
            <th class="col-2">Bla 2</th>
            <th class="col-2">Bla 3</th>
            <th class="col-2">Bla 4</th>
            <th class="col-2">Bla 5</th>
            <th class="col-1">Bla 6</th>
            <th class="col-1">Bla 7</th>
            <th class="col-3">Bla 8</th>
            <th class="col-3">Bla 9</th>
            <th class="col-1">Bla 10</th>
            <th class="col-3">Bla 11</th>
            <th class="col-3">Bla 12</th>
            <th class="col-3">Bla 13</th>
            <th class="col-3">Bla 14</th>
            <th class="col-2">15</th>
        </tr>
        </thead>
        <tbody>
        {% for item in bla %}
            <tr class="d-flex">
                <td class="col-1">{{ item.bla1 }}</td>
                <td class="col-2"></td>
                <td class="col-2">{{ item.bla3 }}</td>
                <td class="col-2">{{ item.bla4 }}</td>
                <td class="col-2">{{ item.bla5 }}</td>
                <td class="col-1">{{ item.bla6 }}</td>
                <td class="col-1">{{ item.bla7 }}</td>
                <td class="col-3">{{ item.bla8 }}</td>
                <td class="col-3">{{ item.bla9 }}</td>
                <td class="col-1">{{ item.bla10 }}</td>
                <td class="col-3">{{ item.bla11 }}</td>
                <td class="col-3">{{ item.bla12 }}</td>
                <td class="col-3">{{ item.bla13 }}</td>
                <td class="col-3">{{ item.bla14 }}</td>
                <td class="col-2">{{ item.bla15 }}</td>
            </tr>
        {% else %}
            <tr>
                <td colspan="14">no records found</td>
            </tr>
        {% endfor %}
        </tbody>
    </table>

Answer №1

I successfully resolved the issue by utilizing the following styling techniques:

    td , th {
        display: block;
    }

    thead , tbody {
        display: flex;
    }

    tr {
        width: 100%;
    }

An alternative solution is to assign a set width to each col element as demonstrated below:

th.col-1 , td.col-1 {
    min-width: 100px;
    max-width: 100px;
}

th.col-2 , td.col-2 {
    min-width: 150px;
    max-width: 150px;
}

th.col-3 , td.col-3 {
    min-width: 200px;
    max-width: 200px;
}

Here is the functional code incorporating solution 1:

td , th {
display: block;
}

thead , tbody {
display: flex;
}

tr {
width: 100%;
}
/*
th.col-1 , td.col-1 {
min-width: 100px;
max-width: 100px;
}

th.col-2 , td.col-2 {
min-width: 150px;
max-width: 150px;
}

th.col-3 , td.col-3 {
min-width: 200px;
max-width: 200px;
}
*/
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">

<style type="text/css">


  </style>
</head>
<body>

<table class="table-responsive table-sm">
<thead>
<tr class="d-flex">
<th class="col-1">Bla 1</th>
<th class="col-2">Bla 2</th>
<th class="col-2">Bla 3</th>
<th class="col-2">Bla 4</th>
<th class="col-2">Bla 5</th>
<th class="col-1">Bla 6</th>
<th class="col-1">Bla 7</th>
<th class="col-3">Bla 8</th>
<th class="col-3">Bla 9</th>
<th class="col-1">Bla 10</th>
<th class="col-3">Bla 11</th>
<th class="col-3">Bla 12</th>
<th class="col-3">Bla 13</th>
<th class="col-3">Bla 14</th>
<th class="col-2">Bla 15</th>
</tr>
</thead>
<tbody>
<tr class="d-flex">
<td class="col-1">Bla 1</td>
<td class="col-2">Bla 2</td>
<td class="col-2">Bla 3</td>
<td class="col-2">Bla 4</td>
<td class="col-2">Bla 5</td>
<td class="col-1">Bla 6</td>
<td class="col-1">Bla 7</td>
<td class="col-3">Bla 8</td>
<td class="col-3">Bla 9</td>
<td class="col-1">Bla 10</td>
<td class="col-3">Bla 11</td>
<td class="col-3">Bla 12</td>
<td class="col-3">Bla 13</td>
<td class="col-3">Bla 14</td>
<td class="col-2">Bla 15</td>
</tr>
</tbody>
</table>

<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.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
</body>
</html>

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

PHP login system that retrieves information from a selected database

Currently, I am in the process of creating a login system using PHP, but I have encountered an error: Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/a9356103/public_html/login.php on line 13 The code sni ...

Gin and Golang: Implementing HTML files with CSS styling

I am still learning English, so please bear with me :) My issue is that when using Gin to load HTML, my HTML file contains an import (/stylesheet/index.css), but when I run my app with Gin, it gives an alert that the stylesheet file could not be loaded. ...

Adding HTML elements dynamically using jQuery: A how-to guide

My objective is to start with one element upon loading the page, and this element should have an ID of "something_O". When the user clicks on an add link, a new identical HTML element should be added underneath the existing element. The new element should ...

What is the best way to merge 60 related jquery functions into a unified function?

I designed a webpage that serves as an extensive checklist. When you click on the edit button for a checklist item, a modal window opens up. This modal window contains a radio button to indicate whether any issues were found during the check. If "Yes" is s ...

Obtaining the field name from a SQL Server database by utilizing the field ID

When viewing my selections, I have several drop-down lists that display the ID and I would like the name to be shown to the user for clarity. However, when I list everything that has been added, it displays the chosen ID instead of the name. I attempted t ...

Can we stop a specific container from resizing on mobile devices?

My goal is to have the entire page scale down, except for the navigation container. I'm adjusting some CSS rules to improve accessibility on smartphones, but the issue arises with the multiple images it uses. I need these images to display in their or ...

The margin of a single flexbox item is not aligned properly

The flexbox I have contains several items. All of them are displaying correctly except for the last one, which is expanding to the edge of the div. View the current appearance of the flexbox As shown in the image, the last element is extending to the con ...

How to adjust background size for Iphone4 and Iphone5 simulators using only HTML5 and CSS3 code

Creating an HTML5 app for iPhone4 and 5 with a texture-rich background. I'm facing an issue where the texture image gets scaled and only the central part is visible, even though the image size is 640x960 and 640x1136. I've tried adding @2x at the ...

What is the best way to incorporate two banners on the Magento homepage alongside my flexslider?

I recently made the switch from using a camera.js slider on my website to a Flexslider. The reason for this change was that I couldn't make the camera.js slider clickable, and I wanted to eliminate the 'Click here' button. However, now that ...

Issue encountered during deployment of React on an express server

After successfully creating a simple React website and Express server, I encountered an issue when trying to deploy the website on my own server. While the scripts, CSS, title, and favicon all seem to be loading correctly, the actual content is not display ...

Leveraging CSS to automatically number nested sections

Assume we have an example HTML or XML document structured like this: <body> <section> <h1>This should be numbered 1</h1> <section> <h1>This should be numbered 1.1</h1> <p>blah& ...

What is the solution for adjusting the positioning of the `<select>` element in Bootstrap?

Here is a snippet of HTML code: <button class="btn">hello</button> <select class="input-small"><option>1</option></select> <button class="btn">world</button> The position of the select element is not correc ...

Add a sublime project with a specific directory path

Currently, I am using Sublime Text 2 for a project that is structured as follows: public vendors a.css b.css myfile.less myfile.css (compiled) I am facing an issue where I need to exclude the css files from the main 'public' folder (specifi ...

Tips on saving a form submit button data to localStorage

As a newcomer, I am on a quest to make this function properly. My goal is to create a form where the submit button saves data to the localStorage. Here's what I have tried thus far. <script> function storeRecipe() { localStorage.setItem($(" ...

What is the method in PHP to send an HTML file along with a value in response to a POST request?

I have a PHP file where I want to include a dropdown list and submit button. The dropdown list should display filenames for the user to choose from. Once the user selects a filename from the dropdown list and clicks the submit button, the PHP file should r ...

Exploring Android Webview capabilities using HTML 5 geolocation

Utilizing a webview to load a web application, I am using the HTML 5 geolocation API within the page to detect the user's location. While this feature works seamlessly in all browsers and even in an iOS application, I am facing issues getting it to fu ...

Setting the maximum width for images across various Bootstrap responsive sizes: a step-by-step guide

I'm struggling with optimizing images of varying sizes in bootstrap to ensure they are responsive without losing quality. Current Image: https://i.sstatic.net/akoNy.jpg Desired Image: https://i.sstatic.net/37VFX.jpg HTML: <div class="row"> ...

I am interested in extracting information from a website by utilizing PHP

Can data be scrapped from a website using PHP without the use of any external tools? I attempted with the following code, but it proved to be insufficient: <?php $url = 'http://www.example.com'; $output = file_get_contents($url); echo $output ...

Is AsciiEffect.js compatible with CSS3DRenderer.js in combination with three.js/WebGL?

Having trouble using the AsciiEffect.js and CSS3DRenderer.js together, wondering if it's possible without tweaking... here's the concept var W = window.innerWidth, H = window.innerHeight; renderer = new THREE.CSS3DRenderer(); effect = new THREE. ...

Utilize TypoScript to inject HeaderData prior to implementing Style Definitions

My goal is to include my Google Tag Manager script before the style definitions in order to optimize the loading order and prioritize font-family rendering. Currently, I achieve this by: page.includeCSS { file1 = fileadmin/templates/css/bootstrap.css page. ...