0

I'm struggling since hours with a flyin in Internet Explorer 11.

I have a header with two child elements. I display them with flexbox space-between. The second element (on the right side of the header) has position relative and a child element which has position absolute. On click, I animate the position of the element with position absolute by using transform translateY, so it will slide in directly below the right element in the header. This works on every browser expect IE11, where the flyin is to much on the right (a vertical overflow is visible) and where the width is excluding the last element.

When I use padding-right: 100px; on the element .header__selection, the flyout is on the right of the viewport and the box width covers all elements. Also when I remove position relative on the parent element, the box width is correct. I have no idea whats wrong here. I guess some problems with position and flexbox. Hope for some inputs.

Use the snippet to test on different browsers. Here is a screenshot how it looks on IE11: enter image description here

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>

1 Answer 1

1

I tried to test the issue with IE 11 browser and I can produce the issue with your code.

enter image description here

I try to check the CSS code and found that if you change position from absolute to fixed in .header__selection-flyin class then issue can be solved for the IE 11 browser.

 position: relative;
 to
 position: fixed;

Modified 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>

Output in IE 11 browser:

enter image description here

2
  • This would mean, that my header stays fixed, also if I scroll down when the page is larger? If so, this is not a possible solution, since my header has not to be fixed on the top. I got a solution working and will post it later on here. Thx anyway! Commented Mar 23, 2020 at 9:25
  • Thanks for informing us about the status of the issue. As you had already found the solution I suggest you post your solution and try to mark it as an answer to this question. It can help other community members in the future in similar kinds of issues. Thanks for your understanding. Commented Mar 24, 2020 at 5:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.