Center div in IE5.x?
-
29-06-2021 - |
سؤال
I have the following HTML:
<div id="container">
<div id="header"><h1>Sed sollicitudin dignissim justo, sed.</h1></div>
</div>
and the following CSS:
div#container
{
text-align:left;
width:500px;
margin:0 auto;
}
This creates a div container
which spans across the whole screen, and another div header
within the first div container
, where the second div has a fixed width and is centered in the first div.
This works fine in IE6 but in IE5.x, it doesn't seem to center, it is aligned to the left of the screen.
How do I center this in IE5.x?
المحلول
IE 5.x centres blocks as if there were inline elements.
#containers_parent { text-align: center; }
#container { text-align: left; } /* To reset the alignment for the text inside */
نصائح أخرى
if the only thing you have on the page is #container just add <center>
at the top
لا تنتمي إلى StackOverflow