我以前见过它,也做过,所以我知道它的工作非常稳定,然而,我想知道这是否有效,以及是否有我没有考虑过的警告。
例如:http://jsfiddle.net/sfctB/67/我最近为一些有FF溢出问题的人提供了这个修复,这个问题是由框大小属性引起的。添加简单的-moz-前缀也可以修复它,但我选择了对我来说更有效的方法。我设置了内容div的顶部和底部,使其始终在固定的页眉和固定的页脚之间伸展。然后设置边距以避免溢出。
我会直观地认为同时使用top和bottom或right和left会产生问题,然而,它似乎所做的是,当有一个已经声明的left时,让right表现得有点像宽度,而当已经有一个top声明时,让bottom表现得像高度。
但这是有效的吗?在考虑长期支持时,我应该使用它吗?
代码
html, body {
height:100%;
width:100%;
overflow:hidden;
}
body {
padding: 60px 0px;
height: 100%;
}
.header {
height:60px;
background:#000;
color:#fff;
width: 100%;
position: fixed;
top:0;
}
.body {
overflow-y: scroll;
position:fixed;
bottom:0;
top:60px;
margin: 0 0 60px 0;
}
.footer {
height:60px;
background:#000;
position:fixed;
bottom:0px;
width:100%;
color:#fff;
}
<!DOCTYPE html>
<html>
<head></head>
<body>
<div class="header">This is header</div>
<div class="body">[content here]</div>
<div
class="footer">This is footer</div>
</body>
</html>发布于 2013-01-29 04:29:45
问得好。我想知道这一点已经很长时间了,所以我去了规范( http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width和http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-height)。它看起来像是一个完全拼写出来的,答案是你所期望的。对于绝对定位的元素,如果宽度为"auto“,并且定义了left和right,则:
5. 'width' is 'auto', 'left' and 'right' are not 'auto', then solve for 'width'对于高度也是如此:
5. 'height' is 'auto', 'top' and 'bottom' are not 'auto', then 'auto' values for 'margin-top' and 'margin-bottom' are set to 0 and solve for 'height'然而,我认为tPlummer提出了一个很好的观点。规范和现实可能是两个不同的东西;特别是当涉及到较旧的浏览器时。
发布于 2013-01-29 04:01:41
据我所知,这是有效的加价。我已经看到padding属性在IE中有问题,但在大多数事情上IE也是如此。
https://stackoverflow.com/questions/14569936
复制相似问题