Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE 11 issue with flexbox item with max-width

In IE 11 when an item items don't properly center if they have maximum width property. This example however works in Chrome and Firefox.

JS Bin

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: blue;
  width: 100%;
}

.red {
  background-color: red;
  flex-grow: 1;
  display: flex;
  max-width: 200px;
}
<div class="container">
  <div class="red">non centered box</div>
</div>
like image 317
ZZB Avatar asked Jun 02 '15 17:06

ZZB


People also ask

Is flexbox supported in ie11?

Note also that Internet Explorer 11 supports the modern display: flex specification however it has a number of bugs in the implementation.

How do I set flexbox item width?

A flexbox item can be set to a fixed width by setting 3 CSS properties — flex-basis, flex-grow & flex-shrink. flex-basis : This property specifies the initial length of the flex item. flex-grow : This property specifies how much the flex item will grow relative to the rest of the flex items.

Does Flex not work with IE?

Internet Explorer doesn't fully support Flexbox due to: Partial support is due to large amount of bugs present (see known issues).


2 Answers

It is a bug. But according to IE Feedback it was supposed to be fixed already.

As a workaround, you can remove flex-grow: 1; if you don't have to use it.

like image 88
Stickers Avatar answered Oct 05 '22 06:10

Stickers


Explicitly set width: calc(100%); so IE knows the box width and center it properly.

like image 26
Eric Liu Avatar answered Oct 05 '22 06:10

Eric Liu