您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何将页脚保持在屏幕底部

如何将页脚保持在屏幕底部

您正在寻找的是 CSS Sticky Footer

* {

  margin: 0;

  padding: 0;

}



html,

body {

  height: 100%;

}



#wrap {

  min-height: 100%;

}



#main {

  overflow: auto;

  padding-bottom: 180px;

  /* must be same height as the footer */

}



#footer {

  position: relative;

  margin-top: -180px;

  /* negative value of footer height */

  height: 180px;

  clear: both;

  background-color: red;

}





/* Opera Fix thanks to Maleika (Kohoutec) */



body:before {

  content: "";

  height: 100%;

  float: left;

  width: 0;

  margin-top: -32767px;

  /* thank you Erik J - negate effect of float*/

}


<div id="wrap">

  <div id="main"></div>

</div>



<div id="footer"></div>
其他 2022/1/1 18:14:02 有494人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶