IE9的条件CSS无法正常工作

时间:2012-06-12 20:53:49

标签: css internet-explorer

在我的网站上,我有一张搜索结果表。它在Firefox和Chrome中心对齐,但不是IE9。我正在使用以下条件CSS但显然它不起作用,它仍然在IE9中保持对齐。

<!--[if IE 9]>
<style type="text/css">
.ie9fix {
    width: 75%;
    position: absolute;
    margin-left: auto;
    margin-right: auto; 
    float: center;
}
</style>
<![endif]--> 

我需要更改代码才能使表格中心对齐?

1 个答案:

答案 0 :(得分:0)

如果你真的需要绝对定位:

<style>
.example {position: absolute; left: 0; top: 0; width: 100%; }
.example > DIV {margin: 0 auto; width: 75%; }
</style>

<div class="example"><div>
    ...
</div></div>

这应该在浏览器中保持一致,而不需要特别针对IE9。