页面底部固定于页面底部

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);
                  }
          });

posted @ 2014-03-18 17:07  kaixinkaixin0  阅读(205)  评论(0)    收藏  举报