【发布时间】:2016-05-13 21:18:06
【问题描述】:
我使用本指南使页脚固定在底部:http://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/
本指南使用弹性框来完成这项工作。它在 Chrome 和 Firefox 甚至 Edge 上都能完美运行。但是在 IE11 上,所有元素都像这张图片一样相互折叠:
代码演示:
body {
min-height: 100%;
position: relative;
}
.container {
display: flex;
min-height: 100vh;
height: 100%;
flex-direction: column;
}
.Site {
display: flex;
min-height: 100vh;
flex-direction: column;
background-color: green;
}
.Site-content {
flex: 1;
background-color: red;
}
footer {
background-color: blue;
height: 50px;
}
<body class="Site">
<div id="react-root">
<div class="container">
<main class="Site-content">Site</main>
<footer>Footer</footer>
</div>
</div>
</body>
知道如何解决这个问题吗?在此先感谢:-)
【问题讨论】:
-
IE11 as per caniuse.com/#search=flex 仍然部分支持 flexbox,因此这可能是问题的原因,但由于您的布局很简单,您应该尝试不使用 flexbox..
-
@DhavalChheda 实际上我想将页脚粘贴到底部。我使用了其他技术,包括将页脚设置为底部。但他们都有问题。一种方法将页脚保持在底部,但是当内容溢出时,页脚会在它们之上。最大的问题是因为我在真实站点中使用 React,所以内容和页脚不会是 body 的直接子级。