views:

62

answers:

2

I need to fix a footer to the bottom of the viewport. IE 6 is the problem--and yes, it must work in IE 6. That much, is not my call.

Using this:

div#footer {
 width:1020px;
 position: absolute; 
 top: expression(0+((e=document.documentElement.scrollTop)?e:document.body.scrollTop)+'px'); 
 left: expression(50%+((e=document.documentElement.scrollLeft)?e:document.body.scrollLeft)+'px');} 
}

In my IE6.css I can fix the footer to the top of the page. But if I switch it to this:

div#footer {
 width:1020px;
 position: absolute; 
 bottom: expression(0+((e=document.documentElement.scrollBottom)?e:document.body.scrollBottom)+'px'); 
 left: expression(50%+((e=document.documentElement.scrollLeft)?e:document.body.scrollLeft)+'px');} 
}

It goes haywire. Am I implementing the expression function wrong for fixing it to the bottom of the viewport?

Thanks!

A: 

Try using this instead of expressions:

* {
    margin: 0;
}
html, body {
    height: 100%;
    overflow: auto;
}
.wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: auto;
}
.box {
    position: fixed;
    left: 50%;
    top: 180px;
    margin: 0 0 0 -370px;
}
* html .box { 
    position: absolute;
}

/*

Fixed Positioning in IE6 
http://ryanfait.com/

*/
Preston Marshall
As the ie6.css stylesheet? or just generally?
Fuego DeBassi
Not that I don't appreciate this method, but I'm mostly interested in getting the syntax of the expression tag to work for a bottom positioned element!
Fuego DeBassi
+1. Down voting a valid and proven method makes no sense.
Mike
This method is for IE 6 only. I found it by Googling.
Preston Marshall
+2  A: 

Don't use the expression clause. From my experience it can render the page a little on the slow side and behaves oddly. Some times it'll work and others it'll simply fail not gracefully.

I've had good success with these methods.

But without seeing your entire page it's a little harder to see if any of the links I provided will get in the way of your current stylesheet.

Mike