简体   繁体   English

条件CSS仅适用于firefox

[英]Conditional CSS Only for firefox

I want to use gradient for background in Mozilla Firefox Like 我想在Mozilla Firefox中使用渐变作为背景

 background: -moz-linear-gradient(#C6991D, #F7D065) repeat scroll 0 0 transparent;

And for other browsers im using background-color Like 对于其他浏览器,即时消息使用的是背景颜色,例如

 background-color: #DFB542;

I need to put condition only for firefox. 我只需要为Firefox设置条件。 I know the condition for IE 我知道IE的条件

 <!--[if IE 6]>
     instructions for IE 6 here
 <![endif]-->

But not for firefox. 但不适用于Firefox。 Plz help me. 请帮我。

Thanks! 谢谢!

this does not need conditionals 这不需要条件

background-color: #DFB542;
background: -moz-linear-gradient(#C6991D, #F7D065) repeat scroll 0 0 transparent;

since -moz- is a vendor-specific prefix by itself, only firefox reads it. 由于-moz-本身就是特定于供应商的前缀,因此只有Firefox会读取它。 it' ignored by other browsers. 它被其他浏览器忽略。

placing it in this order in your CSS, firefox will read the first declaration and then the second will override or cascade over the first. 将其按此顺序放置在CSS中,firefox将读取第一个声明,然后第二个声明将覆盖第一个声明或级联

on other browsers, they read the first declaration but ignore the seconds since they don't know how to parse it. 在其他浏览器上,他们读取第一个声明,但忽略秒,因为他们不知道如何解析它。 they skip over the second declaration. 他们跳过了第二个声明。

Firefox doesn't understand conditional comments, only IE does. Firefox不理解条件注释,只有IE可以。 So Firefox simply skips on <![if !IE 7] and <![endif] as unrecognized tags but it render the rest. 因此,Firefox仅跳过<![if !IE 7]<![endif]作为无法识别的标签,而将其余部分呈现出来。 It means that you cannot use content- revealing comments here, only content-hiding ones. 这意味着您不能在此处使用显示内容的注释,而只能使用隐藏内容的注释。

See this post 看到这个帖子

You can do it with javascript 您可以使用javascript

if(navigator.appCodeName=='Mozilla' || navigator.appCodeName=='Netscape'){
   document.write('<style type="text/css">');

   //document.write('your css code');

   document.wirite('</style>');
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM