http://ryanfait.com/resources/footer-stick-to-bottom-of-page/css
Add the following lines of CSS to your stylesheet. The negative value for the margin in .wrapper
is the same number as the height of .footer
and .push
. The negative margin should always equal to the full height of the footer (including any padding or borders you may add).html
* {web
margin: 0;app
}less
html, body {ide
height: 100%;this
}spa
.wrapper {code
min-height: 100%;htm
height: auto !important;
height: 100%;
margin: 0 auto -4em;
}
.footer, .push {
height: 4em;
}
Follow this HTML structure. No content can be outside of the .wrapper and .footer div
tags unless it is absolutely positioned with CSS. There should also be no content inside the .push div
as it is a hidden element that "pushes" down the footer so it doesn't overlap anything.
<html>
<head>
<link rel="stylesheet" href="layout.css" ... />
</head>
<body>
<div class="wrapper">
<p>Your website content here.</p>
<div class="push"></div>
</div>
<div class="footer">
<p>Copyright (c) 2008</p>
</div>
</body>
</html>
http://jingyan.baidu.com/article/2fb0ba4054805900f2ec5f9d.html
//footer吸底效果 var _ch = $("#content").height();//這個就是你中間內容div的高度 var _wh = $(window).height();//整個窗口的高度 //console.log("window's height",_wh,"content's height",_ch,"_wh - _ch:",_wh - _ch); if(_wh - _ch > 192){ $("#content").css("min-height",(_wh-192)+"px"); } //但願這段代碼對你有用!