Css 粘脚比不粘脚';不适用于所有页面

Css 粘脚比不粘脚';不适用于所有页面,css,sticky-footer,sticky,Css,Sticky Footer,Sticky,我目前正在一个网站上工作,需要一种粘性页脚,但不是在所有地方 所以 对于主页,页脚会自动粘贴到底部,但对于其他页面,它不会这样做 我如何使用CSS让它粘到底部 页脚div的当前CSS #footer{ clear:both; float:left; width:100%; border-top:solid 1px #d1d0d0; background-color:#f1efef; margin-bottom:-10px; } 我能做的最好的一件

我目前正在一个网站上工作,需要一种粘性页脚,但不是在所有地方

所以

对于主页,页脚会自动粘贴到底部,但对于其他页面,它不会这样做

我如何使用CSS让它粘到底部

页脚div的当前CSS

#footer{
    clear:both;
    float:left;
    width:100%;
    border-top:solid 1px #d1d0d0;
    background-color:#f1efef;
    margin-bottom:-10px;
}

我能做的最好的一件事就是把页脚推离页面底部,这样它总是离开屏幕底部。下面是如何执行此操作的示例。stickyfooterfail分区不起作用,我也不知道为什么,但是如果将
位置
设置为绝对值,则
底部
属性可以正常工作

<html>
  <head>
    <style type='text/css'>
body {
height: 100%;
}

#fullheight {
background:#ff0;
position: relative;
min-height: 100%;
}
#stickyfooterfail {
position: relative;
bottom: 0px;
}

#stickyfooter {
background: #f0f;
}
    </style>
  </head>
  <body>
    <div id='fullheight'>
      Some text<br>
      Some text<br>

      Some text<br>
      <div id='stickyfooterfail'>
        Should be at the bottom but isn't
      </div>
    </div>
    <div id='stickyfooter'>
        This is pushed off the bottom by the min-height attribute of #fullheight
    </div>
  </body>
</html>

身体{
身高:100%;
}
#全高{
背景:#ff0;
位置:相对位置;
最小高度:100%;
}
#粘滞失效{
位置:相对位置;
底部:0px;
}
#粘脚{
背景:#f0f;
}
一些文本
一些文本
一些文本
应该在底部,但不是 这是由#fullheight的minheight属性从底部推出的

如果您知道页脚将是一个恒定的绝对大小,那么可以将
padding bottom
设置为-(height)例如-40px,如果它是40px高,然后将#stickyfooterfail的
bottom
设置为相同的值。

由于相对定位的元素是相对于其在流中的原始位置定位的,所以
#stickyfooterfail
不起作用。因此,设置
bottom:0
意味着您正在从原始位置向上移动div zero像素的底部。也就是说,一点也不。当我阅读它的规则时,我误解了,因为我认为它是相对于父元素定位的。谢谢你的澄清。