IE7 中页面不居中
在 Safari 中工作正常,但 IE7 左对齐。 http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=160653524585#ht_500wt_1372
有什么办法使它也以 IE 为中心吗?谢谢
.container {
width:980px;
background-position: center;
padding: 0;
margin: auto;
font-family: "Trebuchet MS";
font-size: 12px;
}
</style>
</head>
<body>
<div class="container">
<div class="clear">dfgfdg</div>
</div>
编辑:
有人也有 eBay 帐户来测试吗?我知道这很厚颜无耻,但我相信很多人都会受益!
编辑2:
此代码仍然呈现在左侧,并且非常烦人,因为它可以完成:
.wrapper
{
margin: 0 auto 0 auto;
width: 980px;
text-align: center;
}
.container
{
width: 100%;
text-align: left;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<div class="wrapper">
<div class="container">
your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.
</div>
</div>
</body>
</html>
呈现此: http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=160653524585#ht_500wt_1156
eBay 上居中页面示例:http://stores.ebay.co.uk/Argos-Outlet (已检查代码,似乎使用与下面建议的相同的代码,但仍然无法让它工作。
Works fine in Safari but IE7 it left aligns. http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=160653524585#ht_500wt_1372
Any way of making it so it centres in IE too? Thanks
.container {
width:980px;
background-position: center;
padding: 0;
margin: auto;
font-family: "Trebuchet MS";
font-size: 12px;
}
</style>
</head>
<body>
<div class="container">
<div class="clear">dfgfdg</div>
</div>
EDIT:
Anybody got an eBay account to test on too? Cheeky I know but am sure a lot of people would benefit!
EDIT 2:
This code still renders to the left and is really annoying because it can be done:
.wrapper
{
margin: 0 auto 0 auto;
width: 980px;
text-align: center;
}
.container
{
width: 100%;
text-align: left;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<div class="wrapper">
<div class="container">
your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.your content here.
</div>
</div>
</body>
</html>
Renders this: http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=160653524585#ht_500wt_1156
Example of centered page on eBay: http://stores.ebay.co.uk/Argos-Outlet (have checked code and seems to use same code as suggested below but still can't get it to work at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
解决方案: http://jsfiddle.net/vonkly/GweVX/
<强>CSS
HTML
Solution: http://jsfiddle.net/vonkly/GweVX/
CSS
HTML
你应该能够做到这一点:
当我将 IE9 置于 IE7 模式时对我有用。 (无法在真实的 IE7 上进行测试。)
You should just be able to do this:
Works for me when I put IE9 into IE7 mode. (No way to test on real IE7.)
这也使 DIV 居中
This centers the DIV as well
你可以用另一个div包裹你的div:
然后html将像这样:
You can wrap you div with another one with this:
and then the html will go like this:
将
margin: auto;
更改为margin: 0 auto 0 auto;
要使文本左对齐,请输入
text-align: left;
Change
margin: auto;
tomargin: 0 auto 0 auto;
To make the text aligned to the left, put
text-align: left;