IE7 中页面不居中

发布于 2024-12-09 09:40:24 字数 2106 浏览 1 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

入怼 2024-12-16 09:40:25

解决方案: http://jsfiddle.net/vonkly/GweVX/


<强>CSS

.container {
    width: 100%;
    padding: 10px 0; /* have some north + south padding */
    background-color: #feefee; /* enter your background color */
}
.aligner {
    display: block;
    width: 980px;
    margin: 0 auto; /* centers this element */
    text-align: center; /* centers the text */
}

HTML

<div class="container">
    <div class="aligner">
        Lorem ipsum dolar sit amet, amet sit dolar ipsum lorem.
    </div><!-- /aligner -->
</div><!-- /container -->

Solution: http://jsfiddle.net/vonkly/GweVX/


CSS

.container {
    width: 100%;
    padding: 10px 0; /* have some north + south padding */
    background-color: #feefee; /* enter your background color */
}
.aligner {
    display: block;
    width: 980px;
    margin: 0 auto; /* centers this element */
    text-align: center; /* centers the text */
}

HTML

<div class="container">
    <div class="aligner">
        Lorem ipsum dolar sit amet, amet sit dolar ipsum lorem.
    </div><!-- /aligner -->
</div><!-- /container -->
剑心龙吟 2024-12-16 09:40:25

你应该能够做到这一点:

.clear{
    text-align:center;
}

当我将 IE9 置于 IE7 模式时对我有用。 (无法在真实的 IE7 上进行测试。)

You should just be able to do this:

.clear{
    text-align:center;
}

Works for me when I put IE9 into IE7 mode. (No way to test on real IE7.)

太阳公公是暖光 2024-12-16 09:40:25
.center {
    position: absolute:
    margin-left: -490px;
    left: 50%;
}

<div class="center"> </div>

这也使 DIV 居中

.center {
    position: absolute:
    margin-left: -490px;
    left: 50%;
}

<div class="center"> </div>

This centers the DIV as well

葬シ愛 2024-12-16 09:40:25

你可以用另一个div包裹你的div:

.wrapper 
{
margin: 0 auto 0 auto;
width: 980px;
text-align: center;
}

.container
{
width: 100%;
text-align: left;
}

然后html将像这样:

<div class="wrapper">
  <div class="container">
    your content here.
  </div>
</div>

You can wrap you div with another one with this:

.wrapper 
{
margin: 0 auto 0 auto;
width: 980px;
text-align: center;
}

.container
{
width: 100%;
text-align: left;
}

and then the html will go like this:

<div class="wrapper">
  <div class="container">
    your content here.
  </div>
</div>
简单气质女生网名 2024-12-16 09:40:25

margin: auto; 更改为 margin: 0 auto 0 auto;

要使文本左对齐,请输入 text-align: left;

Change margin: auto; to margin: 0 auto 0 auto;

To make the text aligned to the left, put text-align: left;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文