How to automatically center div in IE8 in quirksmode?

I am working with IE8 in quirks mode ...

I have styles cascading from my Firefox stylesheet, which include:

#container {position:relative; width:1007px; margin-right:auto; margin-left:auto;} #textbin {width:720px; position:relative; margin-right:auto; margin-left:auto;} 

Apparently I am not doing anything right, or auto-labeling is not working in IE8. This is true? If so, how can I get around this limitation? I did not try to position, absolute positioning, and even added a relative position to my IE8 stylesheet. Also, when I manually center the div, IE8 adds an edge to the bottom of the page ...

By the way, I'm new here, so if you need more information, please let me know!

+6
html css internet-explorer-8 quirks-mode
source share
2 answers

The old-school hack-y way to do this is to add text-align:center to the parent element you want to center. Of course, you will need to specifically declare the text-align property for the children, if you do not want them to be centered, since text-align inherited by the children.

+7
source share

This will work for querks IE5 and higher.

css:

 body, html { width:100%; } #yourdivname { margin:0px 50% 0px 50%; //this can be removed, but is just for test sake. background-color:#bbb; width:100px; height:100px; } 

Hope this helps, good wishes Bert Yang.

0
source share

All Articles