footer始终在页面最底部的方法(问题待检验)

一。css方法

<style type="text/css">
html,body{
height: 100%;
}
body{
display: flex;
flex-direction: column;
height: 100%;
}
.head{
flex: 0 0 auto;
}
.content{
flex: 1 0 auto;
}
footer{
background: #333;
flex: 0 0 auto;
}
</style>

二。js方法

<script type="text/javascript">
// 判断窗口高度,使footer始终在底部
$(document).ready(function(){
if($(document.body).height()<$(window).height()){
$(".footer").css({"position":"fixed","bottom":"0px"});
}
})
</script>

原文地址:https://www.cnblogs.com/jianmeng/p/7554960.html