在固定位置的div我如何保证金值设置为固定定位的div
#abs{
position: fixed;
bottom: 0;
background-color: red;
padding: 20px;
width: 100%;
margin-top: 200px;
}
但margin-top: 200px;
不起作用应用这个CSS。
这里是demo
是否有与jQuery的方法吗?
在固定位置的div我如何保证金值设置为固定定位的div
#abs{
position: fixed;
bottom: 0;
background-color: red;
padding: 20px;
width: 100%;
margin-top: 200px;
}
但margin-top: 200px;
不起作用应用这个CSS。
这里是demo
是否有与jQuery的方法吗?
固定定位从文档流中取出一个元素,所以不要弄乱元素的边距。如果你不能改变HTML尝试添加
body {
margin-bottom: 200px;
}
顺便说一句,如果你真的需要添加一些内容到页面的底部,但只能访问样式表,您可以使用此:
body:nth-last-child(1):after {
content: "aha ";
line-height: 200px;
}
尝试给margin-bottom:200px; for the top div class #someid
这也给出了同样的结果 Check This
编辑
添加position: relative;
,而不是固定的,那么这将是工作。
#abs{
position: relative;
bottom: 0; background-color: red;
padding: 20px;
width: 100%;
margin-top:200px;
}
#someid{
position:absolute;
height: 700px;
background-color: yellow;
width: 100%;
}
#abs{
position:absolute;
background-color: red;
padding: 20px;
width: 100%;
margin-top:200px;
}
顶部使用不仅没有边距使用顶部将扩大股利 – akash
。但我需要差距之间的差距。 http://jsfiddle.net/T5yg7/8/ –
我需要这样的http://jsfiddle.net/T5yg7/11/,但没有在小提琴的#someid设定保证金。 –