Friday, April 15, 2011

How do I get the push footer trick to work in IE 8?

I use this:

body {font-size:12px; font-family:"trebuchet MS", verdana, arial, sans-serif; background: #CCCCCC; word-wrap:break-word; height: 100%; margin: 0; padding: 0;
}

#wrapper {
    text-align: left;
    height:auto;
    height: 100%;
    margin: 0 auto -200px; /* the bottom margin is the negative value of the footer's height */
    padding: 0px;
    border:0;
    width: 1000px;
    background: #FFFFFF;


.footer, .push {
    height: 200px; /* .push must be the same height as .footer */
    position:absolute;
}

It looks as if it works fine in Firefox/Safari/Opera and IE 6 and 7 but not in 8. What's missing or wrong?

From stackoverflow
  • Your code had some big holes in it, so I had to make some guesswork. You could test this one out, it seems to work the same on ff3, ie7 and ie8 that I tested.

    I'm not sure if it's something that you wanted, but you really should provide an better example with your question.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>test</title>
        <style type="text/css">
    html{
        height:100%;
        margin: 0; 
        padding: 0;
    }
    body {
        font-size:12px; font-family:"trebuchet MS", verdana, arial, sans-serif; 
        background: #CCCCCC; 
        word-wrap:break-word; 
        height: 100%; 
        margin: 0; 
        padding: 0;
    }
    
    #wrapper {
        text-align: left;
        height:auto;
        height: 100%;
        margin: 0 auto -200px; /* the bottom margin is the negative value of the footer's height */
        padding: 0px;
        border:0;
        width: 1000px;
        background: #FFFFFF;
    }
    
    .footer, 
    .push {
        height: 200px; /* .push must be the same height as .footer */
        position:absolute;
        bottom:0;
        background:red;
    }
    
        </style>
    </head>
    <body>
        <div id="wrapper">Lorem</div>
        <div class="footer">Footer jabba jibba jubba hubba bubba dubba dibba dei</div>
    </body>
    </html>
    

    I hope that helps.

    Mikko Tapionlinna : Well, you could accept my answer :)

0 comments:

Post a Comment