HTML的footer置于页面最底部的方法

footer高度任意+js

fixed-bottom{position:fixed;bottom:0;width:100%;}

$(function(){

  $("#footer").removeClass("fixed-bottom");

  var contentHeight = document.body.scrollHeight,//网页正文的高度

    winHeight = window.innerHeight;//可视窗口高度

  if(!(contentHeight > winHeight)){

    $("#footer").addClass("fixed-bottom")

  } else{

    $("footer").removeClass("fixed-bottom")

  }

})

posted on 2018-05-21 10:38  金翅鸟  阅读(274)  评论(0编辑  收藏  举报