[Reprinted] CSS Sticky Footer: the absolute bottom of the perfect CSS, stickyfooter

Source: Internet
Author: User

[Reprinted] CSS Sticky Footer: the absolute bottom of the perfect CSS, stickyfooter

The following is a perfect method I have found. It can be achieved by a foreign designer, pure CSS: when there is very little content in the body, the bottom is at the bottom of the window. No overlap occurs when the window height is changed.

<div id="wrap">    <div id="main" class="clearfix">        <div id="content">        </div>        <div id="side">        </div>    </div></div><div id="footer"></div>

Description: The premise of using this layout is that footer should use a layer outside the total div container, while all other content uses a total layer. If you do need to add other peer layers, you must use position: absolute for absolute positioning for this peer layer.

CSS code:

The following is the main CSS code, so that your bottom can be located at the bottom of the window:

Html, body, # wrap {height: 100%;} body >#wrap {height: auto; min-height: 100% ;}# main {padding-bottom: 150px ;} /* must use the same height as footer */# footer {position: relative; margin-top:-150px;/* negative value of footer height */height: 150px; clear: both ;}

Description: Note that the padding value of # main, the height of footer, and the negative margin value must be consistent.

It's that simple, but it's not over yet. If your subject uses a floating layout, you have to solve some browser compatibility issues. Here, the focus is on Goolge Chrome.

For the # main part, perform the famousClearfix Hack:

.clearfix:after {content: ".";    display: block;    height: 0;    clear: both;    visibility: hidden;}.clearfix {display: inline-block;}/* Hides from IE-mac \*/* html .clearfix { height: 1%;}.clearfix {display: block;}/* End hide from IE-mac */

Note: This solution is tested on two-bar floating layout and is compatible with major browsers, including Google Chrome.

Reprinted from: http://paranimage.com/css-sticky-footer/


CSS fixed at the bottom of footer

First, we need to separate the DIV from the overall DIV,
Set the CSS style of the DIV
Bottom: 0;
Position: fixed;

Fixed the question at the bottom of footer with CSS?

# Container {position: absolute; top: 0; left: 0 ;}# footer {position: absolute; bottom: 0; left: 0 ;}
 

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.