使用@ -moz-document url-prefix()在SCSS中定位Firefox [英] Using @-moz-document url-prefix() to target Firefox in SCSS
问题描述
我试过了以下,但是父参考&
#nav li {
display:table-cell;
@ -moz-document url-prefix(){
& {
display:inline-block;
$ div class =h2_lin>解决方案
首先我安装: https:// github.com/rafaelp/css_browser_selector
这给了我浏览器和每个浏览器的渲染类:
< html class =gecko firefox firefox26 mac>
然后在我的SCSS中,我可以这样做:
.foo {
display:block;
.firefox& {
display;没有;
}
}
这个例子在Firefox中隐藏了.foo。使用& 之后,选择器查找树状结构。也可以安装脚本并创建一个单独的firefox.scss,然后像下面这样启动它:
$ b $ s$ b
$ b
.firefox {
//在这里做东西
}
通常情况下,使用Modernizr之类的功能检测比使用特定浏览器更容易,但有时需要解决各种浏览器问题。
Is there an easy way to use "@-moz-document url-prefix()" to target Firefox in SCSS documents.
I have tried the following, but the parent reference "&" does not work in this context.
#nav li{
display: table-cell;
@-moz-document url-prefix(){
& {
display: inline-block;
}
}
}
I run into little issues like that from time to time. I mainly use this technique to fix IE8. Here's my fix:
First I install: https://github.com/rafaelp/css_browser_selector
This gives me browser and rendering classes for each browser:
<html class="gecko firefox firefox26 mac">
Then in my SCSS, I can do this:
.foo{ display: block; .firefox & { display; none; } }
This example hides .foo in Firefox. Using a & after the selector looks back up the tree. Isn't SASS awesome?!?!?
Alternatively, install the script and create a separate firefox.scss and just start it like so:
.firefox {
// Do stuff here
}
As a rule, feature-detection using something like Modernizr is easier than playing to specific browsers, but sometimes you need to address various browser issues.
这篇关于使用@ -moz-document url-prefix()在SCSS中定位Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!