absolute positioning and css sticky footer

岁酱吖の 提交于 2019-12-04 11:38:46
Joe Conlin

I typically just use the following to "stick" a div to the bottom of the page (or container):

.footer {position:absolute;bottom:0;left:0;}

Once you set position to absolute, it becomes independent of external divs and their position/dimensions.

Sam Hunter

I recommend Ryan Fait's sticky footer, works very well!

* {
  margin: 0;
}

html,
body {
  height: 100%;
}

.wrapper {
  min-height: 100%;
  height: auto !important;
  /* This line and the next line are not necessary unless you need IE6 support */
  height: 100%;
  margin: 0 auto -20px;
  /* the bottom margin is the negative value of the footer's height */
}

.footer,
.push {
  height: 20px;
  /* .push must be the same height as .footer */
}
<body>
  <div class="wrapper">
    <p>Your website content here.</p>
    <div class="push"></div>
  </div>
  <div class="footer">
    <p>Copyright (c) 2008</p>
  </div>
</body>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!