Centering an absolute DIV horizontally in IE8

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

.holder-answers {
    position: absolute;
    display: none;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    top: 200px;
    width: 501px;
}
+5
source share
1 answer

Can you 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.

+8
source

All Articles