Flexbox 在 Internet Explorer 11 中不起作用 [英] Flexbox not working in Internet Explorer 11

查看:39
本文介绍了Flexbox 在 Internet Explorer 11 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这段代码在 Firefox、Chrome 和 Edge 中运行良好,但显然由于 flex 模型在 IE11 中无法正常运行.我该如何解决?

This piece of code works fine in Firefox, Chrome and Edge, but it does not work properly in IE11 because of flex model, apparently. How can I fix it?

Firefox 中的样子

这就是它在 IE11 中的样子

body * {
  box-sizing: border-box;
}
html {
  height: 100%;
}
body {
  min-height: 100%;
  display: flex;
  flex-flow: column;
  margin: 0;
}
main {
  flex: 1;
  display: flex;
}
header,
footer {
  background: #7092BF;
  border: solid;
  width: 100%;
}
section {
  border: solid;
  background: #9AD9EA;
  flex: 1
}
aside {
  border: solid;
  width: 150px;
  background: #3E48CC
}

<header>
  <p>header
</header>
<main>
  <aside>
    <p>aside
    <p>aside
  </aside>
  <section>
    <p>content
    <p>content
    <p>content
    <p>content
  </section>
</main>
<footer>
  <p>footer
  <p>footer
</footer>

推荐答案

根据 Flexbugs:

在 IE 10-11 中,弹性容器上的 min-height 声明用于调整容器本身的大小,但它们的弹性项目子项似乎不知道其父项的大小.它们就好像根本没有设置高度一样.

In IE 10-11, min-height declarations on flex containers work to size the containers themselves, but their flex item children do not seem to know the size of their parents. They act as if no height has been set at all.

这里有几个解决方法:

1.始终填充视口 + 可滚动

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆