为什么容器不在 Internet Explorer 中居中?
我有我的作品集,在所有浏览器中看起来都很棒,但在 Internet Explorer 中,容器似乎没有居中,我正在使用 margin: 0 auto;
但它不起作用。如何在 Internet Explorer 中修复?
这是代码的链接: http://christianbovine.com/
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 working. How can I to fix in Internet Explorer?
Here is the link to the code:
http://christianbovine.com/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
旧版本的 IE 需要不礼貌地使用文本对齐,如下所示:
添加宽度纯粹是为了参考,添加边距纯粹是为了跨浏览器兼容性。
对于你的情况,我建议添加第二个“容器”div(即containerInner),然后你可以在CSS中添加如下内容:
Older versions of IE require the ingracious use of text-align, like so:
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:
在父元素中,使用“text-align”属性。例如:
In the parent element, use the "text-align" attribute. For example:
使用
text-align:center
作为正文标记或将所有内容包装在标记内。另外,您可能需要考虑使用
display:inline-block
。这允许您指定元素的宽度和高度属性(如果它只是设置为内联而不是块,则宽度和高度属性将被忽略)(如果是这种情况)。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.