如何为firefox和ie设置不同的z-index?

时间:2013-09-22 13:56:08

标签: css

索引css属性值101但我在firefox中需要99。

我试过这个

<!--[if gte IE 7]>
    z-index: 101;
<![endif]-->
z-index:99;

但它对我没有用。

如何为不同的浏览器提供相同属性的不同valude?

3 个答案:

答案 0 :(得分:2)

<style type="text/css">
  #my-div{
    z-index: 99;
  }
</style>

<!--[if gte IE 7]>
<style type="text/css">
  #my-div{
    z-index: 101;
  }
</style>
<![endif]-->

IE条件注释适用于HTML而非CSS,因此您需要将它们从CSS中取出并将CSS选择器/逻辑包装在<style>标签内。确保首先声明默认行为。

答案 1 :(得分:1)

这些评论:

<!--[if gte IE 7]>

需要在CSS代码之外,以及HTML标记。

例如:

<!--[if gte IE 7]>
<style type="text/css">
    .selector {
        z-index: 101;
    }
</style>
<![endif]-->

答案 2 :(得分:0)

我想使用http://rafael.adm.br/css_browser_selector/它易于使用,特别是当你必须在你的网站上有jquery时,使用这个insetad。 干杯