简体   繁体   English

Firefox的条件CSS语句

[英]conditional css statement for firefox

I'm having problems with css in firefox, therefore I want to import a css file only if the browser is FF 我在firefox中遇到css问题,因此我只想在浏览器为FF时导入css文件

Actually, I need to import this styles: 实际上,我需要导入以下样式:

.searchbutton{
    position:absolute; right:3px;  width:25px;  
    top:3px;
}

#buscarmain{ bottom:12px;

}

EDIT: 编辑:

Many have argued that I shouldn't use a special statement for FF, since FF is most probably to be correct, compared to other browsers. 许多人认为我不应该对FF使用特殊说明,因为与其他浏览器相比,FF最有可能是正确的。

However, in this case all browsers print the same page (IE, Chrome, Opera, Safari) and FF displays it in another way. 但是,在这种情况下,所有浏览器都打印同一页面(IE,Chrome,Opera,Safari),而FF以另一种方式显示该页面。 I must achieve the same visualization for all browsers, therefore I need a special FF statement 我必须为所有浏览器实现相同的可视化效果,因此我需要特殊的FF语句

Here is how we can target CSS styles only for Firefox: 这是我们仅可以针对Firefox定位CSS样式的方法:

<style type="text/css">
@-moz-document url-prefix() {
    h1 {
        color: red;
    }
}
</style>

Source: Targeting only Firefox with CSS 来源: 仅使用CSS定位Firefox

您可以尝试使用CSS浏览器选择器

solved the problem 解决了问题

just added: 刚刚添加:

    <script type="text/javascript">
    if ( $.browser.mozilla == true ) {
      document.write("<link type=\"text/css\" rel=\"stylesheet\" href=\"FF.css\">");
    }
</script>

IE is the only browser with conditional comments. IE是唯一带有条件注释的浏览器。 I've always felt that every browser should have their own, but alas. 我一直觉得每个浏览器都应该有自己的功能,但是a。

I think the solution is to tweak your style sheet so that it displays properly in Firefox and then fix for IE. 我认为解决方案是调整样式表,使其在Firefox中正确显示,然后修复IE。

A rough and very dirty solution would be to use JavaScript to detect the browser and add a class such as "ffonly" to the body tag if the browser is Firefox. 如果浏览器是Firefox,则粗略且非常肮脏的解决方案是使用JavaScript来检测浏览器,并在body标签中添加“ ffonly”之类的类。 Then always bring in your Firefox stylesheet but put ".ffonly " at the begining on all your style rules 然后,始终引入Firefox样式表,但在所有样式规则的开头都添加“ .ffonly”

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

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