属性为 position:absolute; 的DIV的高度等于Body的高度 不用JS就用CSS能实现吗

如题所述

第1个回答  2013-01-08
div{
position: absolute;
height: 100%;
width: 100%;
background: red;
}
<div></div>

ie6是不支持的,ie6空元素默认的百分百就是默认的行高。
第2个回答  2013-01-08
<body style="width:100%; padding:0; margin:0; height:1440px; position:relative; background:#000;">
<div style="position:absolute; padding:0; margin:0; width:100%; height:100%; background:#666;">
</div>
</body>
前提是body的高度得超过屏幕的高度才可以本回答被提问者采纳
第3个回答  2021-02-06

Vue实践-CSS样式position/display/float属性对比使用

第4个回答  2013-01-08
上下左右都设为0,或宽高都设为100%。追问

我把DIV设置了100% 都占不满Body

追答

body边距跟填充去掉

第5个回答  2013-01-08
问题没有表达清楚
相似回答