在绝对div上设置高度100% [英] Set height 100% on absolute div

查看:109
本文介绍了在绝对div上设置高度100%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了覆盖100%高度div 的问题。我可以使用位置固定解决封面,但这不是我真正想要的,因为你应该能够向下滚动覆盖>所以分辨率低于我的人可以看到整个内容。

I am facing a problem with overlaying a 100% height div. I could use position fixed to solve the cover, but that's not really what I want because you should be able to scroll down on the 'cover' > so people with lower resolutions than mine can see the entire content.

代码示例:

HTML

<body>
<div>Overlay example text</div>
</body>

CSS

body {
    float: left;
    height: 3000px;
    width: 100%;
}
body div {
    position: absolute;
    height: 100%;
    width: 100%;
    background-color: yellow;
}

问题:包含100%的webbrowser / viewport,但我想要覆盖整个身体。

The problem: The div's height 100% only contains 100% of the webbrowser/viewport, but I want it to cover the entire body.

提前感谢:)

推荐答案

http://jsbin.com/ubalax/1 / edit 。您可以在此处看到结果

http://jsbin.com/ubalax/1/edit .You can see the results here

body {
    position: relative;
    float: left;
    height: 3000px;
    width: 100%;
}
body div {
    position: absolute;
    height: 100%;
    width: 100%;
    top:0;
    left:0;
    background-color: yellow;
}

这篇关于在绝对div上设置高度100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆