CSS troubleshooting: Incorrect element sizing and placement in Internet Explorer 11 (issues with flexbox, positioning, and transforms)

I've been wrestling for hours with a frustrating issue in Internet Explorer 11.

The problem lies within a header that contains two child elements. I'm using flexbox space-between to display them. The second element, positioned on the right side of the header, has position relative and a child element with position absolute. On click, I animate the position of the absolute-positioned element using transform translateY, causing it to slide directly below the right element in the header. This works perfectly on every browser except IE11, where the flyin extends too far to the right (resulting in vertical overflow) and cuts off the last element's width.

If I add padding-right: 100px; to the element .header__selection, the flyout shifts to the right within the viewport and covers all elements correctly. Additionally, removing position relative from the parent element ensures the box width is correct. I'm stumped as to why this behavior is happening, but suspect it may be related to positioning and flexbox. Any insights would be greatly appreciated.

Feel free to use the snippet provided to test across different browsers. You can view a screenshot of how it appears on IE11 here: https://i.sstatic.net/8bFge.png

const selection = document.querySelector('.header__selection');
const flyin = document.querySelector('.header__selection-flyin');

selection.addEventListener('click', function() {
  flyin.classList.toggle('state-header__selection-flyin--open');
});
body {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.header {
  background-color: white;
  border-bottom: 1px solid gray;
  
  display: flex;
  justify-content: space-between;
  align-items: center;
  
  height: 60px;
  width: 100%;
}

.header__selection {
  position: relative;
}

.header__selection-flyin {
  display: flex;
  background-color: lightcoral;
  border: 1px solid black;
  position: absolute;
  transform: translateY(-100%);
  transition: transform 0.3s ease-in-out;
  right: 0;
  z-index: -1;
}

.header__selection-flyin-item {
  padding: 5px 10px;
}

.state-header__selection-flyin--open {
  transform: translateY(100%);
  z-index: 1;
  transition: transform 0.3s ease-in-out, z-index 0.3s 0.2s;
}
  
<header class="header">
  <div class="header__logo">Logo</div>
  <div class="header__selection">
    <div class="header__selection-active">
      Selected Item
    </div>
    <div class="header__selection-flyin">
      <div class="header__selection-flyin-item">Item</div>
      <div class="header__selection-flyin-item">Item</div>
      <div class="header__selection-flyin-item">Item</div>
    </div>
  </div>
</header>

Answer №1

After conducting a test on IE 11 browser, I was able to replicate the issue using your code.

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

I delved into the CSS code and discovered that changing the position property from absolute to fixed in the .header__selection-flyin class could resolve the issue for IE 11 browser.

 position: relative;
 to
 position: fixed;

Revised code:

const selection = document.querySelector('.header__selection');
const flyin = document.querySelector('.header__selection-flyin');

selection.addEventListener('click', function() {
  flyin.classList.toggle('state-header__selection-flyin--open');
});
body {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.header {
  background-color: white;
  border-bottom: 1px solid gray;

  display: flex;
  justify-content: space-between;
  align-items: center;

  height: 60px;
  width: 100%;

}

.header__selection {
  position: relative;

}

.header__selection-flyin {
  display: flex;
  background-color: lightcoral;
  border: 1px solid black;
  position: fixed;
  transform: translateY(-100%);
  transition: transform 0.3s ease-in-out;
  right: 0;
  z-index: -1;

}

.header__selection-flyin-item {
  padding: 5px 10px;

}

.state-header__selection-flyin--open {
  transform: translateY(100%);
  z-index: 1;
  transition: transform 0.3s ease-in-out, z-index 0.3s 0.2s;
}
<header class="header">
  <div class="header__logo">Logo</div>
  <div class="header__selection">
    <div class="header__selection-active">
      Selected Item
    </div>
    <div class="header__selection-flyin">
      <div class="header__selection-flyin-item">Item</div>
      <div class="header__selection-flyin-item">Item</div>
      <div class="header__selection-flyin-item">Item</div>
    </div>
  </div>
</header>

Displayed Output in IE 11 browser:

https://i.sstatic.net/NJYEO.gif

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

Top choice for asp.net form tooltip?

Searching for a tooltip solution to provide input instructions to users filling out a form. Recommendations for a user-friendly, straightforward code or plugin? Specifically looking for tooltips that appear when a textbox is selected, with the capability ...

Having difficulty achieving the hover transition effect

I've been working on a navbar design and I'm having trouble getting the hover effect to work on the links. Specifically, I am trying to add a transform property to the after element of the links but it doesn't seem to be taking effect. #navb ...

yii2 truncates CSS classes in the email templates

My email sending process involves using a template: $content='Message'; Yii::$app->mailer->compose('@app/mail/templates/templ', ['content'=>$content]) ->setFrom('<a href="/cdn-cgi/l/email-protection" c ...

Looking to integrate the date, month, and year selection tags into the inline format

The Edit User Profile page includes a Birthday field, which is currently displayed vertically. I am looking to change the layout so that the Birthday field appears horizontally. Here is the code I am using: Within visitors/edit.html.erb, <%= simple_f ...

Parallel Bootstrap vertical grid layout

Struggling to articulate my objective, but bear with me. I am in the process of creating two bootstrap grids to house expanding text boxes. Refer to the image below for a visual representation; Desired Outcome Despite my efforts, the output from my code ...

Having trouble understanding why the content in my div becomes cramped when the div collapses

Currently, I am working on a portfolio page in React. One issue I'm facing is that when I collapse a div, the content gets scrunched up and I can't figure out what's causing it. I tried using "white-space: nowrap;" but it doesn't seem t ...

Attempting to decipher the @media queries CSS code responsible for the slider on this particular website

I'm having trouble with the cover not fully expanding when the browser size is less than 750. I am new to using bootstrap. For reference, I am looking at this website: CSS .slide-wrapper { position: relative; } /* Not using now .carousel-caption ...

Determining the browser width's pixel value to enhance responsiveness in design

Lately, I've been delving into the world of responsive design and trying to grasp the most effective strategies. From what I've gathered, focusing on content-driven breakpoints rather than device-specific ones is key. One thing that would greatl ...

How can I retrieve the width of a responsive React element during its initial rendering phase?

In my React project, there is a component called ResultList which is used to display products in a gallery format. The challenge I'm facing is determining the appropriate number of products to show per row based on the available width for the ResultL ...

Exploring CSS Outlining in Visual Studio 2013

Back in the days of Visual Studio 2010, whenever you opened a CSS file, a window would automatically pop up displaying all the classes and IDs for easy navigation within the file. However, in Visual Studio 2013, I seem to be unable to locate this helpful ...

Is there a way to create an image gallery layout similar to Pinterest using CSS?

I am currently developing a dynamic PHP gallery that will feature thumbnails with the same width but varying heights. These thumbnails will be arranged from left to right, so I would prefer not to use a traditional five-column layout. I suspect that achiev ...

Using CSS to layer one element on top of another element

Check out this website at There seems to be an issue with the image being cut off. I am looking to have the content in div contentTextWill overlap the rightSideBar. Is this achievable? Below is the code snippet: <div class="contentWrapper"> <d ...

Elements that are hidden or not displayed are still able to receive mouse over events

I am in the process of learning how to handle events within svgs and I have encountered a strange issue. Currently, I am working on an infovis project where I create an interface to display various column-graphs. This part is functioning well so far. Ho ...

Attempting to create a responsive design for profile pictures and texts

Seeking advice on making my profile picture and About me text responsive, utilizing Bootstrap v5 with percentages for responsiveness. Wondering if there is a more efficient way to ensure the profile picture looks good on phones, tablets, and 1080p screens. ...

When viewing Google maps in full screen mode, the image suddenly vanishes

I have a map with a logo positioned in the lower right corner near the controls. However, when I switch to full screen mode, the logo disappears. I can see the div (aggdata-info) in Firebug, but the image/logo is not visible. Any suggestions on how to fix ...

How to use JavaScript to hide an element (field) in XPages

In XPages, I understand that only editable fields are able to retrieve values from context. My question is: how can I hide a field using CSS or JavaScript in XPages while still being able to get its value from the context? Many thanks ...

When rails code is placed within haml tags, it results in generating empty spaces within the HTML tags of browsers

Every time a rails variable is nil (or when using rails code (as seen in the third code example)), my html displays a string of empty characters. new.html.haml %h1.editable.editable_title_field{:contenteditable => 'true', :placeholder => ...

Issues arise when attempting to create smooth animations with 100% transform translate across different web browsers

After uncovering an ancient piece of JS code that I had once shared for free use, I discovered that a CSS animation bug from 3 years ago is still causing trouble today. The issue involves animating an element from left:100%/transform: translateX(100%) or ...

When viewed on a mobile device, the entire HTML document is resized to occupy less than half of the

Whenever I adjust the size of my webpage on different devices or mobile phones, I notice that the <div> tag appears to be only half (or even less) the width of the page. This gap seems to increase as the window size decreases. Refer to the screenshot ...

Is specificity a characteristic of JavaScript?

After setting a div in my HTML file to have a height of 100px and a width of 100px, I attempted to retrieve the height using JavaScript. This is what I tried: console.log(document.GetElementById("box").style.height); // The div had an ID of "box" and w ...