如果你的内部div有绝对的高度(比方说100px),你可以这样做:
.outerdiv{
position: relative; //or absolute, or fixed
height: 80%;
}
.innerdiv{
position: absolute;
width: 100px;
height: 100px;
top: 50%; // it's at 50% but not really centered
margin-top: -50px; // so just move it up by the half of its height :D
}
Run Code Online (Sandbox Code Playgroud)
我不喜欢这个解决方案非常mutch并且我确信还有很多其他的可能性(可能使用表格或者display: table-cell;) - 但这是我想到的第一个......