lennysan
lennysan

Reputation: 1350

Centering absolute DIV horizontally in IE8

Is it possible to an center a div horizontally, if that div is also absolute? The following works great in Chrome/Safari/Firefox, but in IE8 it sits to the far left:

.holder-answers {
    position: absolute;
    display: none;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    top: 200px;
    width: 501px;
}

Upvotes: 5

Views: 3001

Answers (1)

Chris
Chris

Reputation: 3795

Can you not try:

.holder-answers {
    position: absolute;
    top: 200px;
    left: 50%;
    width: 501px;
    margin-left: -250px; /* half the box width */
}

This method should work in all browsers.

Upvotes: 9

Related Questions