页面底部固定于页面底部

body,html{margin: 0 auto;padding: 0;height:100%;}

.containt_main{min-height: 100%;_height: 100%;position: relative;}

 <div class="containt_main">

    <div class='footer'  style=' position:absolute;bottom:0;'> </div>

 </div>

一定要有html的css,containt_main的min-height: 100%;,然后footer:position:absolute;bottom:0;

 

页面高度不够的情况下:

页面放大缩小的时候好像会有问题,该为动态计算高度:$("#main").height($(document).height() - 129 - 104);

129为top的高度,104为foot的高度。

 

最终:

 if($(document).height() - 129 - 104 >  $("#main").height()){
           $("#main").height($(document).height() - 129 - 104);
          }
      $(window).resize(function() {
         if($(document).height() - 129 - 104 > $("#main").height()){
                   $("#main").height($(document).height() - 129 - 104);
                 // alert($(window).height() +' '+$(document).height() + '  '+document.body.scrollHeight +'  '+document.body.clientHeight +'  '+document.body.offsetHeight);
                  }
          });

转载于:https://www.cnblogs.com/kaixiner/p/3608179.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值