css - 动态DIV高度

标签 css

在我的页面的头部

<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/

相关文章:

html - 相同 CSS 类(Bootstrap 中的 .thumbnail)的图像以各种尺寸显示

PHP 在单独的代码块中显示动态填充的变量

css - 如何使用 CSS 制作文本并遵循图像大小

html - 无法让 "@media screen and"工作

html - :hover not working on div, 正在处理页面的其他部分

html - 我可以使用纯 CSS 根据 URL 的获取参数设置链接样式吗?

javascript类检查

css - 如何使内容过于剪辑路径形状 div?

jquery - 获取所有未悬停的元素并对它们进行处理

css - 为什么在添加标签 css 时链接在 jsp 中不起作用?