页面不以IE7为中心

时间:2011-10-12 19:01:23

标签: html css internet-explorer-7 alignment center

在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(已检查过代码,似乎使用了下面建议的相同代码,但仍无法使其完全正常工作。

5 个答案:

答案 0 :(得分:3)

解决方案: 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 -->

答案 1 :(得分:0)

你应该能够做到这一点:

.clear{
    text-align:center;
}

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

答案 2 :(得分:0)

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

<div class="center">&nbsp;</div>

这也是DIV的中心

答案 3 :(得分:0)

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

要使文字与左侧对齐,请添加text-align: left;

答案 4 :(得分:0)

你可以用另一个包装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>