Issue with max-width in IE11 when using a display: table parent element with display: flex child elements

When viewing the code below, everything appears correctly in Chrome. The width of the .inner element is limited by max-width.

However, in IE11, the .inner element expands to fit all content.

If I were to set display: block for either the .container or .inner element, everything works as expected. But this solution is not viable as the issue is within a larger component used across multiple sites, and I do not want to risk breaking anything.

  1. Why is this happening?
  2. Is there a way to resolve this issue without changing the display properties?

.container {
  background-color: yellow;
  display: table;
  height: 100px;
  max-width: 277px;
}

.inner {
  background-color: red;
  display: flex;
  height: 50px;
}
<div class="container">
  <div class="inner">77 777 777 77 7 7777 77 7 7 7 77 7 7 7 77 7 7 7 7 7 77 7 7 7 7 77 7 77 7 7 77 7 7 77 7 7 77 7 7 77 7 7 7 7 7</div>
  <div class="inner">111 11111 111111111111 111111111111 111111111 111111111111 11111111111 11111111111 11111111 1111111111 11111</div>
</div>

Answer №1

Typically, issues with flexbox in IE11 are a common occurrence, as highlighted on this GitHub repository.

Introducing a <table> element as the parent of flex containers can lead to unforeseen challenges since table cells are normally the children of tables.

Moreover, including overflowing content can provoke IE11 to disrupt your layout entirely.

To address the issue, it is advisable to incorporate two key rules into your code:

 .container {
    width: 100%;              /* new */
    table-layout: fixed;      /* new */
    display: table;
    max-width: 277px;
    height: 100px;
    background-color: yellow;
}

.inner {
    background-color: red;
    display: flex;
    height: 50px;
}
<div class="container">
    <div class="inner">77 777 777 77 7 7777 77 7 7 7 77 7 7 7 77 7 7 7 7 7 77 7 7 7 7 77 7 77 7 7 77 7 7 77 7 7 77 7 7 77 7 7 7 7 7</div>
    <div class="inner">111 11111 111111111111 111111111111 111111111 111111111111 11111111111 11111111111 11111111 1111111111 11111</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

I am looking for a way to batch upload several images from an HTML page to a nodejs server, where I can then rename and

Exploring the world of nodejs, I am seeking guidance on updating multiple images from HTML to node js. Specifically, how can I rename each image differently and save them to a directory? Alternatively, is there another solution that would better suit my ne ...

Creating a designed pattern for a textbox: Let's get creative with your text

How can I create a Textbox that only allows numeric values or the letter 'A'? <input type="text" id="txt" name="txt" pattern="^[0-9][A]*$" title="Allow numeric value or only Letter 'A'&quo ...

Is there a glitch in Safari's CSS involving max-height?

Currently, I am in the process of developing a popup for a registration form. The CSS rules have been configured accordingly and after testing on various browsers, it has come to my attention that Safari is displaying an additional white space between elem ...

How can "this" be properly utilized in jQuery?

I am attempting to retrieve the title attribute of an element from various elements with the same class, each having different attributes. This is my current approach: HTML <div title="title1" class="pager" onclick="location.href='link.aspx& ...

Tips for efficiently moving through divs in a personalized single page application?

Exploring the world of JS frameworks and single page app functionality is a bit of a mystery to me. Currently, I have a pseudo single page app set up without any specific framework in place. The setup involves 3 tabs that toggle visibility for 3 different ...

Tips for automating dialog box scroll with selenium in Java

I'm attempting to automate the Instagram website, but when I click on the followers link it opens a dialog box with users to follow. However, when I try to scroll within that dialog box, it ends up scrolling the main page rather than the followers dia ...

The scroll header remains fixed in size despite being responsive

I've been struggling to resize a fixed header when the page is scrolled. Unfortunately, I'm having trouble getting the header to adjust its size as the scrolling happens. $(document).scroll(function() { navbarScroll(); }); function navbarSc ...

Are you looking to analyze inputs and tally up any duplicates?

I am working on a form that requires users to input up to 20 1-4 character codes. My goal is to count each code entered and present the output in the following format: AB //entered once EFOO //entered once AACC x 2 //because AACC was entered twice into fo ...

Setting the selected option in a Razor HTML Select/Option after a postback

Currently, I have a HTML select element with 3 options. My goal is to specify which option should be selected after a post back on my form. The technologies I am using include Razor (C#), HTML, jQuery, and CSS. If possible, I would like to achieve this ...

Automating testing for numbered lists with CSS list-style-type decimal

I need help with a JavaScript and CSS project. I have a situation where I have a numbered list like this: Coffee Tea Cola Here is the code structure I am using: <!DOCTYPE html> <html> <head> <style> ul.a {list-style-type ...

Add the output of an SQL query to an HTML table using Powershell

I have multiple databases from various SQL Servers. I am attempting to output SQL data to an HTML table using Powershell from these different databases/SQL Servers, and then send it via email. Although my current script is functioning, it generates multip ...

What could be causing the vertical gap between my divs?

My issue revolves around the spacing between three divs on a webpage, where the middle content div is consistently about 50px away from both the header and footer divs. I'm puzzled as to why this separation keeps happening since I haven't define ...

Creating a notification system similar to Facebook's in an HTML button using just HTML and CSS

I'm attempting to create a button with a notification feature that mimics the style of Facebook notifications. I want a small red circle in the top right corner, showing a numerical value. However, I'm running into some difficulties. I can' ...

What is the best way to showcase information in Angular?

I am facing an issue where my cards are not displaying data from the database, they appear empty. Can anyone provide a solution to help me fix this problem? Below is the output I am getting, with the empty cards that I want to populate with data. https:// ...

CSS border margin-bottom attribute not functioning correctly

I am trying to create a page border by wrapping it around the content using a <div> element. The parent element is the actual page itself. However, I'm having trouble with the margin-bottom property as it doesn't seem to be working properly ...

Transition effects in CSS when hovering

I've run into an issue where I'm attempting to create a hover transition effect on a div when the mouse hovers over it. The idea is that hovering over the main div should trigger another div to appear above it, with a smooth transitioning effect. ...

Preventing links from functioning on dynamically generated web pages

I have implemented the following code to deactivate all links on a preview page: var disableLink = function(){ return false;}; $('a').bind('click', disableLink); While this successfully disables all static links, any anchor tags loade ...

Header and Footer with auto-sizing Body that scrolls

My structure consists of a Header, Body, and Footer <div id="my-element"> <div id="header">...</div> <div id="body"> ... </div> <div id="footer">...</div> </div> Currently, the element with the ...

Incorporating Materialize CSS and MaterialUI within a single React Application

Presently, I have a straightforward non-React application built with HTML, Materialize, and JavaScript that I am considering converting to React while also making the switch from MaterializeCss to MaterialUI. However, I am not looking to make this transiti ...

When CSS's position:fixed is utilized, overlapping divs may occur when combined with columns

So I have created an HTML layout with rows and columns, resembling this structure: <div class="row"> <div class="col-sm-2 col-lg-2 col-md-2"> Some Code Here </div> <div class="col-sm-10 col-lg-10 col-md-10"> ...