想用CSS垂直居中div。不想要表或Javascript,但只有纯CSS。找到了一些解决方案,但都缺少对Internet Explorer 6的支持。
<body>
<div>Div to be aligned vertically</div>
</body>
如何在所有主流浏览器(包括Internet Explorer 6)中垂直居中div?
我想要一个垂直居中的div,在一个最小高度的父div中。我使用此代码垂直居中我的div:
.parent {
width:100%;
min-height: 25vh;
max-height: auto;
position: relative; /* so center-area can be positioned absolute */
display: inline-block;
background:lightblue;
}
center-area {/* let it fill the whole container */
pos