【发布时间】:2017-09-17 23:48:52
【问题描述】:
我创建了一个简单的设置,其中包含一些使用 flexbox 来控制页面间距的包装器。它有两个具有固定位置的页眉、一个页脚和一些中间的空间,无论页面上实际有多少内容,它们总是垂直填满屏幕的其余部分。
现在我想在 #content_wrapper 和 #header_wrapper 之间添加一个 div,我想根据其内容和浏览器宽度调整其大小。为此,我添加了#sub_header_wrapper div。
这一切都在 Firefox 中按预期工作,但在 Internet Explorer 中,#sub_header_wrapper div 中的文本溢出并开始与 #content_wrapper 文本重叠。为什么会发生这种情况,如何解决?
jsfiddle:https://jsfiddle.net/mevn8bvL/21/
h1,
h2,
h3,
h4,
h5,
h6,
p {
margin: 0;
padding: 0;
}
/* needed to reset CSS so you dont get extra unneeded whitespace */
html,
body {
margin: 0;
/* required to avoid scroll bars due to min-height 100vh */
}
#outer_wrapper {
margin: 0;
height: 0;
/* required by IE to make flex-grow work */
min-height: 100vh;
background-color: pink;
display: flex;
flex-direction: column;
}
/* flex-grow is 99 to offset the variable nature of the sub header containers. */
#content_wrapper {
background-color: green;
flex-grow: 99;
/* this is what makes the div expand even when there's no content. */
}
#article_list {
background-color: red;
}
#header_wrapper {
position: fixed;
width: 100%;
z-index: 199;
box-shadow: 0px 10px 5px rgba(0, 0, 0, 0.2);
}
#header_top_wrapper,
#header_bottom_wrapper {
height: 70px;
min-height: 70px;
/* min-height required to enforce the height */
}
#sub_header_wrapper {
background-color: rgb(150, 150, 255);
margin-top: 140px;
flex: 1 1 auto;
}
#header_top_wrapper {
background-color: yellow;
}
#header_bottom_wrapper {
background-color: orange;
}
#footer_wrapper {
height: 100px;
min-height: 100px;
background-color: blue;
}
<div id="outer_wrapper">
<div id="header_wrapper">
<div id="header_top_wrapper">
header top
</div>
<div id="header_bottom_wrapper">
header bottom
</div>
</div>
<div id="sub_header_wrapper">
sub header with informational text. sub header with informational text. sub header with informational text. sub header with informational text. sub header with informational text. sub header with informational text. sub header with informational text.
sub header with informational text. sub header with informational text. sub header with informational text. sub header with informational text. sub header with informational text. sub header with informational text. sub header with informational text.
sub header with informational text. sub header with informational text. sub header with informational text. sub header with informational text.
</div>
<div id="content_wrapper">
<div id="article_list">
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
</div>
</div>
<div id="footer_wrapper">
footer
</div>
</div>
【问题讨论】:
-
Internet Explorer 的哪个版本?
-
互联网浏览器 11
-
有趣的是,我尝试在资源管理器中打开 jsfiddle,它只是说:不,不支持 IE。
标签: html css internet-explorer flexbox