Why doesn't the container center in Internet Explorer?
I have my portfolio, looks great in all browsers but in Internet Explorer the container doesn't seem to center, I'm using margin: 0 auto;
but it is not wo开发者_运维技巧rking. How can I to fix in Internet Explorer?
Here is the link to the code: http://christianbovine.com/
Older versions of IE require the ingracious use of text-align, like so:
<div style="text-align: center;">
<div style="text-align: left; width: 300px; margin: 0 auto;">
<p>Content goes here</p>
</div>
</div>
Width is added purely for reference, and margin purely for cross-browser compatibility.
In your case, I'd recommend adding a second "container" div (ie. containerInner), and you could then add something like this in CSS:
div#container { text-align: center; }
div#containerInner { text-align: left; }
In the parent element, use the "text-align" attribute. For example:
body{
text-align:center;
}
Use text-align:center
for the body tag or wrap all content inside a tag.
Also, you may want to consider using display:inline-block
. This allows you to specify width and height properties for elements (if it's just set to inline and not block, width and height attributes are ignored) if it's the case.
精彩评论