Css – How to fix Absolute Positioning In IE8


In every browser I've used, except ie8, an absolutely positioned element can be positioned according to the closest parent with relative positioning.

The below code shows two divs inside a table. The top div has position: relative, however, the nested, absolutely positioned element does not respect its boundaries (in ie8, it gets positioned at the bottom of the page instead of the bottom of the parent div).

Does anybody know a fix for this?

#top {
position: relative;
background-color: #ccc;
#position_me {
background-color: green;
position: absolute;
bottom: 0;
#bottom {
background-color: blue;
height: 100px;
    <td><div id="top"> Div with id="top"
        <div id="position_me"> Div with id="position me" </div>
      <div id="bottom"> Div with id="bottom"
        <p>Lorem ipsum dolor sit amet.</p>

Best Solution

Declare a doctype. I'd encourage you to use the HTML5 doctype:

<!DOCTYPE html>