Unable to resize tables in IE when using CSS Flex layout

Having a bit of trouble with the flex layout. I've put together a FIDDLE project where when resizing the output box, table cells will align one to one beneath each other. It seems to work fine in Chrome and Firefox but not in IE when using table elements tr, td.

You can check out the example here

CSS:

tr {
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox !important;
    display: -webkit-flex;
    display: flex;
    -ms-flex-wrap: wrap;
    -moz-flex-wrap: wrap;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
}

td {
    display: block;
}

.cell1 {

}

.cell2{
    width: 500px;
}

.cell3{
    min-width: 300px;
}

HTML:

<h1>real table</h1>
<table>
    <tr class="table">
        <td class="cell1">Cell 1</td>
        <td class="cell2">Cell 2</td>
        <td class="cell3">Cell 3</td>
    </tr>
</table>

<h1>div "table"</h1>
<div class="table">
    <span class="cell1">Cell 1</span>
    <span class="cell2">Cell 2</span>
    <span class="cell3">Cell 3</span>
</div>

Appreciate any help on this!

Solved: To make it work in IE, you need to set display: block on parent elements like tr and table. That should do the trick!

Answer №1

Support for flex-wrap in IE can be achieved on a tr by assigning an explicit width to the tr.

If you desire the width to be dynamic based on the window size, you might consider using JavaScript:

window.onresize = function() {
  var flexItems = document.querySelectorAll('.table');
  for(var j = 0; j < flexItems.length; j++) {
    flexItems[j].style.width = document.body.clientWidth + 'px';
  }
}

window.onresize();

Check out this JSFiddle demo!

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

CSS rules for organizing the stacking order of elements in the SuperFish Menu with

I've been struggling with a z-index issue on a website I'm currently managing. It seems to stem from the z-index values in the SuperFish Menu and a specific div element. Despite my attempts to apply position:relative/absolute & z-index: 99999 dec ...

Attempting to ensure that my website is fully optimized for all devices and

I am currently facing an issue with my CSS code on iPad. I want to change the background-image displayed based on whether the user is using an iPad or not. Specifically, I want to use headerold.jpg as the background-image for iPads while keeping headernew. ...

Text Alignment Issue in Icon Bar of Zurb Foundation 5

There's an unusual problem I'm encountering with the alignment of text under the icon bar not being properly centered below the icons. Here is a snippet of the code: <div class="row"> <div class="small-12 columns"> < ...

Tips for creating a scrollable section within a div row using clarity design instead of bootstrap formatting

My current project combines Angular with .NET Core, and I am encountering difficulties in styling one particular component. This component consists of a row with two columns. The first column is empty while the second column contains another row divided i ...

Is it possible to obtain the index of a table row using querySelector?

Is it possible to find the rowIndex of the first occurrence of a table row within the #myTable using JavaScript? http://jsfiddle.net/bobbyrne01/fmj6np6m/1/ html .. <table id="otherTable"></table> <table id="myTable"></table> js ...

Dynamically changing the .active class and setting aria-current="page" based on the current active webpage

As I work on developing a website, I strive to make code modifications simple and efficient. To achieve this, I have integrated the navbar using <?php require_once('./includes/navbar.php'); ?>. This way, I can make changes site-wide by on ...

The problem of border-radius bleeding in Webkit when applying -webkit-transform

After creating a basic jQuery script to slowly rotate an image, I encountered an issue where the rotated image would bleed over the border-radius in Chrome. The rotation works smoothly in Firefox 4.0.1 but not in Chrome. To see the example and code, check ...

When the application is reloaded, will the localStorage data be reset or remain intact?

Looking for a way to store data consistently throughout my application, I've opted to use localStorage. However, I'm facing an issue where all the localStorage values are erased upon reloading the browser. Can someone shed some light on why this ...

When using the ngFor directive, the select tag with ngModel does not correctly select options based on the specified

Issue with select dropdown not pre-selecting values in ngFor based on ngModel. Take a look at the relevant component and html code: testArr = [ { id : '1', value: 'one' }, { id : '2', ...

Transforming an image by masking it to create a binocular-like view

I've been experimenting with creating a unique visual effect where an image is revealed through a binocular-shaped element that follows the mouse cursor. The circular part of the element moves along with the cursor, unveiling parts of the image as it ...

Can the text box be set up to scroll vertically as you type?

Is there a way to create a vertical scrollable HTML text box that automatically moves to the next line when reaching the width of the textbox while typing, similar to a textarea but without actually using a textarea element? ...

What is the best way to include a JavaScript variable in an HTML image src tag?

Even though I know the answer to this question is out there somewhere, I just can't seem to find it (or maybe I'm not recognizing it when I see it!). As a beginner in jquery, please be patient with me. Dilemma: I have a collection of 20 images, ...

Is it possible to stack navbar items in CSS?

I'm facing an issue with my navbar menu items overlapping on top of each other. https://i.sstatic.net/dEEpx.png What could be the reason behind this? Codepen Link: https://codepen.io/ogonzales/pen/mdeNNLB Code Snippet: <nav class="navbar navb ...

It is proving challenging to fully eliminate top and bottom padding in MUI TableCell in order to enable clickable whole cell content

I've been working on making the content of my table cells clickable for routing within my app, and I've made some progress in removing unclickable horizontal space by adjusting padding. However, I'm still facing issues with unclickable space ...

Leverage PHP to dynamically populate a chart.js visualization with information sourced from an SQLite Database

I'm attempting to use chart.js to display data from an SQLite database using PHP, but I've been running into issues. Despite following multiple online tutorials, my graph remains empty or disappears altogether. This is my first time working with ...

What is the most effective method for incorporating personalized React components in the midst of strings or paragraph tags

Summary: Exploring the frontend world for the first time. Attempting to integrate custom components within p-tags for a website, but facing challenges in making them dynamically changeable based on user interaction. Greetings all! As a newbie in front-end ...

The concept of an HTML pop-up message that hovers above the content

While working on my HTML form, I encountered an issue regarding the display of a warning message notifying users about the caps lock being on. Currently, the warning is shown correctly in a div located to the right of the text box. However, this div's ...

Conceal the message using star symbols

I need help figuring out how to hide a certain type of string input from the user, and then use Angular data binding to display it in another component with part of the data masked with asterisks. I'm not very skilled in JavaScript, so I'm wonder ...

Issue with EaselJS: mouse events are no longer functional

I'm currently working on adding a touch animation using the EaselJs library. Interestingly, when I load an image from a local folder, all mouse events work as expected, such as onPress. However, things take a different turn when I opt to use an imag ...

Clicking a button to reset a json file

I have a task management program and I would like to implement a feature that allows users to reset the tasks to a predefined set of JSON data within the JSON file by simply clicking a button. For instance, if the JSON file contains multiple tasks, clickin ...