在绝对div上设置高度100%

编程入门 行业动态 更新时间:2024-10-28 14:26:57
本文介绍了在绝对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.

提前感谢:)

推荐答案

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

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

本文发布于:2023-10-08 04:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471538.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:高度   div

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!