【发布时间】:2015-03-01 03:47:00
【问题描述】:
如何制作一个元素垂直对齐的跨浏览器解决方案?
http://jsfiddle.net/e2yuqtdt/3/
这适用于 Firefox 和 Chrome,但不适用于 IE11
<div class="page_login">
<div>vertical-align:center; text-align:center</div>
</div>
html, body {
height:100%;
}
.page_login {
display:flex;
height:100%;
width:100%;
background:#303030;
}
.page_login > div {
margin:auto;
background:#fff;
min-height:100px;
width:200px;
}
更新
当居中元素高于视口高度时,背景只有 100% 而不是 100% 滚动高度
http://jsfiddle.net/e2yuqtdt/8/
html, body {
min-height:100%;
height:100%;
}
.page_login {
display:flex;
min-height:100%;
height:100%;
width:100%;
background:#303030;
}
.page_login > div {
margin:auto;
background:#fff;
height:800px;
width:200px;
}
【问题讨论】:
标签: css internet-explorer internet-explorer-10 flexbox