在高度不确定的情况下让div自身垂直和水平局中的终极解决方案(CSS3写法)
<div class='contain' ></div>
<style>
.contain {
position: fixed;
top: 50%;
left: 50%;
width: 600px;
height: auto;
transform: translateX(-50%) translateY(-50%);
}
</style>
<div class='contain' ></div>
<style>
.contain {
position: fixed;
top: 50%;
left: 50%;
width: 600px;
height: auto;
transform: translateX(-50%) translateY(-50%);
}
</style>