After reading this article decided to use the third method, actually very want to use JQ, convenient and flexible, consulted a lot of old-timers, learned that JS control dom in performance impact is relatively large, can use CSS and HTML to solve the use of JS.
Html
The code is as follows |
Copy Code |
<div id= "Container" <div>.........</div>   <div class= "Push" ><!--not put Anything here--></div> </div> <div id= "Footer" >footer section</div CSS html, body{ height:100% margin:0 & nbsp; padding:0; } #container { min-height:100%; height:auto!important; &nbs p; height:100%; The negative value of the margin:0 auto-330px;/*margin-bottom equals footer Height */ } . Push, #footer { & nbsp; height:330px; Clear:both; } |
HTML and Body Tags: html,body tags, like the first two, need to set "height:100%" and reset "margin" and "padding" to 0;
Div#container: Method Three key parts are div# Container settings, the first need to set its minimum height (min-height) of 100%, in order to be compatible with the IE6, you need to be compatible with the Min-height (the specific approach to look at the front or code) in addition there is a key point in the div# You need to set a margin-bottom on the container container and give it negative values, and the value is equal to the height of div#footer and Div.push if div# Footer and Div.push set the padding and border values, then Div#container margin-bottom negative values need to be added div#footer and Div.push. That is to say, "Div#container{margin-bottom:-[div#footer Height+padding+border] or-[div.push Height+padding+border]}". In other words: the Margin-bottom negative value of div#container needs to be consistent with Div#footer and Div.push (if there are padding or border, the height values need to be added to them);
Div.push: We should not place anything in the Div.push, and this div must be placed in the Div#container container and at the bottom, and it needs to set its height value equal to the Div#footer value, preferably with Clear:both to clear the float. The Div.push container works here to push the footer down.
Div#footer Container: Div#footer container and Method Two, cannot be placed inside Div#container, and Div#container container sibling, if you need to set spacing between elements and footer, It is best to use padding instead of the margin value.