[英]Firefox 100% height div - scrollbar showing up
My Problem is described by this Code: 此代码描述了我的问题:
<div class="test"></div>
<div class="extra"></div>
Stylesheet: 样式表:
html, body {
height: 100%;
margin: 0;
padding: 0;
}
div.test {
width: 100%;
background: #ccc;
height: 100%;
}
div.extra {
position:relative;
height:50px;
background:red;
top:-50px;
}
or in this jsfiddle: 或在这个jsfiddle中:
http://jsfiddle.net/XnKmW/3/ http://jsfiddle.net/XnKmW/3/
If you look at it, all things are in place - like they should be. 如果您查看一下,所有内容都已经准备就绪-就像应该的一样。
In Chrome and IE no scrollbar shows up. 在Chrome和IE中,没有滚动条显示。 But in FF there is a scrollbar and you can scroll beyond that red div - this shouldn't be possible!
但是在FF中有一个滚动条,您可以滚动到该红色div之外-这是不可能的!
Making the any of the divs positon:absolute is not the answer I am searching for. 使任何div positon:absolute不是我要寻找的答案。
You get scroll because of this 您因此而得到滚动
div.extra {
position:relative;
height:50px;
background:red;
top: -50px;
}
You are using position: relative;
您正在使用
position: relative;
and than you are subtracting -50px;
然后您减去
-50px;
from top
, instead take relative out and use margin-top: -50px;
从
top
,取相对值并使用margin-top: -50px;
div.extra {
height:50px;
background:red;
margin-top:-50px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.