CSS puts the bottom footer at the bottom of the page

Source: Internet
Author: User

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>
&nbsp
<div class= "Push" ><!--not put Anything here--></div>
</div>
&nbsp;
<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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.