align-items, align-self not working on IE11

大城市里の小女人 提交于 2019-12-18 04:46:16

问题


I have a simple plunker here.

.container {
  display:flex;
  flex-flow: row nowrap;
  justify-content: space-between;
  align-items: center;
  min-height: 4em;
}

.nav {      
  flex: 0 0 4em;
  height: 1em;
}

.logo {
  flex: 1 0 auto; 
  align-self: stretch;
}

This is working how I want it to in Chrome 49:

But not in IE11:

I have checked that IE isn't in compatability mode - it's not - it's in IE11 mode.

What's going on here?


回答1:


This is a bug in IE11.

The min-height property on a flex container isn't recognized by flex items in IE11.

If you switch to height: 4em, you'll see that your layout works.

A simple workaround is to make .container a flex item.

In other words, add this to your code:

body {
    display: flex;
}

.container {
    width: 100%; /* or flex: 1 */
}

For whatever reason, by making your flex container also a flex item, the min-height rule is respected by the child elements.

More details here: Flexbugs: min-height on a flex container won't apply to its flex items



来源:https://stackoverflow.com/questions/40775317/align-items-align-self-not-working-on-ie11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!