在我的页面的头部
<style type="text/css">
html {
overflow: hidden
}
html, body, #centralDIvision {
margin-left: auto;
margin-right: auto;
width: 1100px;
height: 400px;
}
#centralDivision {
float: left;
}
#outer {
display: table;
position: absolute;
height: 100%;
width: 100%
}
</style>
但我不希望 centralDivision div 的高度等于 400px,我希望它是浏览器当前屏幕尺寸的 75%。我有办法做到这一点吗?
最佳答案
只是为了多样性,另一种方法,使用绝对定位:
#parent {
position: relative;
height: 400px;
}
#child {
position: absolute;
top: 12.5%;
bottom: 12.5%;
left: 0;
right: 0;
}
和一个working example on jsFiddle ,当然。
关于css - 动态DIV高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10307270/