Position Fixed Support In IE8

Posted By Weston Ganger

I was working on an application with Internet Explorer 8 and I added a element with position:fixed; and it was not appearing right at all.

Turns out IE8 doesnt implement the fixed position, ridiculous! So after a bit of googling I found a pretty good method, although its a wierd one.

This fix works in IE8 (maybe IE7 too).

.fixed-element{
  position:fixed;
  _position:absolute;

  /* if you want top */
  top:0;
  _top:expression(eval(document.body.scrollTop));

  /* if you want bottom */
  bottom:0;
  _top:expression(document.body.scrollTop+document.body.clientHeight-this.clientHeight);
}

Those underscores are something interesting and I dont know how they work but they do. Anyways this one has javascript in it so be sure to place the rule in the head of your layout with an IE conditional, not in an external stylesheet.

Related External Links:

Article Topic:Software Development - HTML / CSS

Date:October 11, 2015