使用@ -moz-document url-prefix()在SCSS中定位Firefox [英] Using @-moz-document url-prefix() to target Firefox in SCSS

查看:215
本文介绍了使用@ -moz-document url-prefix()在SCSS中定位Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个简单的方法可以使用@ -moz-document url-prefix()来在SCSS文档中定位Firefox。

我试过了以下,但是父参考&

  #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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆