我知道有类似的问题,但我已经尝试了所有的建议,仍然无法让它发挥作用。我正在使用Bootstrap,我有一个高度为100vh的部分。在这一节中,我有两行,第二行我需要放在该部分的最底部,但不想使用绝对定位。因此,我使用了flex系统。
我的布局是这样的
.mn120 {
min-height: 120px;
}
img {
max-width: 40%;
}
.mh100vh {
min-height: 900px;
}
.col-md-4 {
margin-top: auto;
}
<section id="someSection" class="section">
<div class="container d-flex flex-column justify-content-between fHeight mh100vh">
<div class="row">
<div class="col-md-8 offset-2">
<h2 class="section-title">Header Text</h2>
<p class="section-subtitle">
Some Text
</p>
</div>
</div>
<div class="row d-flex fHeight">
<div class="col-md-4">
<img class="btmImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMkAAAD7CAMAAAD3qkCRAAAAMFBMVEX3+fnMzMzNzs72+PjQ0NDv8fHY2dny9PTo6enu8PDi4+Pd3t7U1NTe39/r7OzJycld9/9/AAAFnElEQVR4nO2di5arIAxFGcEXovz/317bTue205ckJ5hxZf9Au5eEQITomqPg8lFwX0fBTPRhJvowE32YiT7MRB9mog8z0YeZ6MNM9CFv0oQQ0pXQiP2OrEmTuiku49j23jnvfbsMXcgyvyVnkptulejdL/zYyfyekEnOKT5afLtEkSEmY9JMrX+ucWZJAr8pYZLiO43LYwnwX8WbpPhiVN3Rxw4sgzYJmzzOz2WMUwoZNpNhTXI3bvS4yPTjMHcNRgZqEpYSjx+dATIvI02mT4H+kn7mBw3OJHycsd7RRu7MjDLJiTKybhkn3j8AmeRu65T1Gj+wcj/GJNND5JYxMaYxjAlGZI18xiwGMUGJsFQAJqCh9a1CHmB8k9wBRdbpmJpZ+CaJP2vdsexlElqsiHNxJ5MBLUKNeq7JDA2SC7QMyTRJAiLOk5ZgPJNctB3ZDClSeCadiIjz1U0a8AT8A2V4cUxyFBJxMyHRc0yCTJSsDHVNssQMfKGva0KqP2zDEzIKwwS7crw3ISwjGSZi8U7LjXQTuXhfISy96CZJUMQR6ix0E8HBtSaUmiZyM5cjpUa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S2+8eP88cG8NtknMl6zdO/LSE9NQuqmofI8tYH27ZcQf5nkk0UcRgUj6hl+mV9OzDcma1R087BvdH/Et8OLucxdLU5fgu29aotvfB+ffWn3ZLImb1WxvYFxevgGsksaY3sDfUz34e/+2MO44Vf47/13ePQ3H6fe+79wOX8FNR/B5IQ/fzl0738BYk0ye/8FFF68AYxhGIZhGIZhGIZhGIZhGIZhGIZhGIZhGIZhGIZhGIZhGIZhGIZhGIbxV/gHsWx5jdRW/s8AAAAASUVORK5CYII=" alt="" />
</div>
<div class="col-md-8">
<img class="btmImg" src="http://www.atfund.gatech.edu/sites/default/files/images/verticalplaceholderimage-440x680.png" alt="" />
</div>
</div>
</div>
</section>
我使用了很多Bootstrap类来帮助我实现这种布局。为了证明这个问题,我已将该部分的高度更改为900px而不是100vh
因此,如果您在Chrome之类的内容中查看此JSFiddle,您会看到图片行位于该部分的底部。但是,如果您在IE11中查看它,您将看到图像行不位于该部分的底部。
有没有办法让这个布局在IE11中运行?
答案 0 :(得分:3)
您可以执行以下两项操作,使其呈现相同的跨浏览器:
在使用flex 列方向时,IE有一个min-height
bug,将display: flex
添加到其父级(section
)解决了
IE也有some issues when it comes to auto margins,因此margin-top: auto
项上的.col-md-4
代替align-items: flex-end
,请在父级row d-flex fHeight
上使用.section {
display: flex; /* added */
}
.row.d-flex.fHeight {
align-items: flex-end; /* added */
}
.mn120 {
min-height: 120px;
}
img {
max-width: 40%;
}
.mh100vh {
min-height: 900px;
}
/*
.col-md-4 {
margin-top:auto;
}
*/
Stack snippet
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<section id="someSection" class="section">
<div class="container d-flex flex-column justify-content-between fHeight mh100vh">
<div class="row">
<div class="col-md-8 offset-2">
<h2 class="section-title">Header Text</h2>
<p class="section-subtitle">
Some Text
</p>
</div>
</div>
<div class="row d-flex fHeight">
<div class="col-md-4">
<img class="btmImg" src="https://i.stack.imgur.com/V5BcV.png" alt="" />
</div>
<div class="col-md-8">
<img class="btmImg" src="http://www.atfund.gatech.edu/sites/default/files/images/verticalplaceholderimage-440x680.png" alt="" />
</div>
</div>
</div>
</section>
&#13;
WaitForText <Target> <value>
&#13;
答案 1 :(得分:0)
我正在将Bootstrap 4类.d-flex
与min-height: 350px;
一起使用,它们在IE11中的容器没有间距/高度问题。通过在flex容器中增加高度来固定。
尝试增加高度
height: 350px;
答案 2 :(得分:0)
除此之外。 我建议使用您自己的.d-flex类。
我已经实现了这个sass脚本:https://gist.github.com/richardtorres314/26b18e12958ba418bb37993fdcbfc1bd
.d-flex-new {
@include flexbox();
width: 100%;
}
这与@Ason中的两个选项结合使用