您的位置:首页 > 其它

固定导航(Sticky nav)

2016-02-05 14:17 190 查看
方法1:

<div class="footer">
</div>

.footer{
  position:fixed;
  bottom:0;
  left:0;
  width:100%;
  _position:absolute;
  _top:expression(documentElement.scrollTop + documentElement.clientHeight - this.offsetHeight);
  overflow:visible;
}

方法2:

CSS Sticky Footer,出自:http://www.cssstickyfooter.com/using-sticky-footer-code.html

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

* {margin:0;padding:0;}
html, body {height: 100%;}
#wrap {min-height: 100%;}
#main {overflow:auto;padding-bottom: 180px;}
#footer {position: relative;margin-top: -180px;height: 180px;clear:both;}
/*Opera Fix*/
body:before {
  content:"";
  height:100%;
  float:left;
  width:0;
  margin-top:-32767px;
}
<!--[if !IE 7]>
<style type="text/css">
  #wrap {display:table;height:100%}
</style>
<![endif]-->

此两种方法亦可用于顶部的导航。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: