配置指南针浏览器支持(Compass 1.x语法)

拉斐尔·拉里纳加(Raphael Larrinaga)

在Compass的0.12.x版本中,我以这种方式定义了对旧版本的支持:

@import "compass/support"

$legacy-support-for-ie6: false;
$legacy-support-for-ie7: true;
$legacy-support-for-ie8: true;
$legacy-support-for-mozilla: false;

@if ($legacy-support-for-ie7) {
  // specific declaration if ie7 is supported
}

我想知道如何Compass 1.x系统之后定义浏览器支持也许是这样的:

// Add support for a specific browser
$browser-minimum-versions: (
  'ie': "7",
  'ie': "8"
);

// Reject browsers
$supported-browsers: reject(browser-versions("ie"), "6", "7", "8");

但它返回该错误(在Compass 1.0.1上运行):

(Line 206 of /Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.1/stylesheets/compass/_support.scss: 5.5 is not known browser.)
西曼侬

通过修改$graceful-usage-threshold变量来排除浏览器如果浏览器X仅拥有4.99%的市场份额,则要将其设置为5

$debug-browser-support: true;
$browser-minimum-versions: (
  "ie": "9"
);
$graceful-usage-threshold: 4.46163;

@import "compass";

.foo {
  @include opacity(.5);
  @include border-radius(10px);
}

输出:

.foo {
  /* Content for ie 8 omitted.
     Minimum support is 9. */
  opacity: 0.5;
  /* Capability border-radius is not prefixed with -moz because 0.25036% of users are affected which is less than the threshold of 4.46163. */
  /* Capability border-radius is not prefixed with -ms because 0% of users are affected which is less than the threshold of 4.46163. */
  /* Capability border-radius is not prefixed with -o because 0% of users are affected which is less than the threshold of 4.46163. */
  /* Capability border-radius is not prefixed with -webkit because 0.1583% of users are affected which is less than the threshold of 4.46163. */
  border-radius: 10px;
}

请注意,这会导致您可能要支持的其他少数族裔浏览器被排除在外。那就是$browser-minimum-versions发挥作用的时候。

$browser-minimum-versions: (
  "ie": "9",
  "safari": "4"
);

输出:

.foo {
  /* Content for ie 8 omitted.
     Minimum support is 9. */
  opacity: 0.5;
  /* Capability border-radius is not prefixed with -moz because 0.25036% of users are affected which is less than the threshold of 4.46163. */
  /* Capability border-radius is not prefixed with -ms because 0% of users are affected which is less than the threshold of 4.46163. */
  /* Capability border-radius is not prefixed with -o because 0% of users are affected which is less than the threshold of 4.46163. */
  /* Capability border-radius is prefixed with -webkit because safari "4" is required. */
  /* Creating new -webkit context. */
  -webkit-border-radius: 10px;
  border-radius: 10px;
}

作品中进行了一些更改,以使其更容易排除旧的浏览器。您可以在此处关注它们:https : //github.com/Compass/compass/issues/1762

如果要为特定的浏览器制定规则,则该$critical-usage-threshold变量起作用:

$debug-browser-support: true;
$browser-minimum-versions: (
  "ie": "9"
);
$critical-usage-threshold: 4.46163;
$graceful-usage-threshold: 4.46163;

@import "compass";

.foo {
  @include for-legacy-browser('ie', '8') {
    color: green;
    // this is based on $critical-usage-threshold by default
    // if $critical-usage-threshold is lower than the version's usage
    // then this content will be generated
  }
  @if support-legacy-browser('ie', '8') {
    color: red;
  }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Compass 1.x的最低浏览器支持示例

来自分类Dev

浏览器对Java类语法的支持

来自分类Dev

通过命令行安装“指南针”会收到错误“ extconf失败,退出代码1”

来自分类Dev

指南针配置因Docker而失败

来自分类Dev

指南针角度/旋转角度,用于跟踪Javascript中X,Y位置的方向

来自分类Dev

指南针侦听器错误

来自分类Dev

指南针侦听器错误

来自分类Dev

如何通过 x.Something1 和 x.Something2“查询语法”组“x”?

来自分类Dev

指南针USB

来自分类Dev

尝试导入图像支持时,指南针编译失败

来自分类Dev

为什么Google Chrome浏览器不支持此JavaScript语法?

来自分类Dev

哪些浏览器支持ECMAScript 6的导入和导出语法?

来自分类Dev

关于编译/监视的指南针配置问题

来自分类Dev

Objective C语法-内部浏览器

来自分类Dev

浏览器无法读取 jsx 语法

来自分类Dev

指南针错误的命令'grunt服务器'

来自分类Dev

运行指南针时出现捆绑器错误

来自分类Dev

将numpy 1d数组用作sklearn X的最短语法

来自分类Dev

不是这样吗?Python x>y "<stdin>",第 1 行和语法错误

来自分类Dev

AngularJS 1.x 和 Angular 5 之间的 Kendo UI 语法是否不同?

来自分类Dev

替换可能不支持X浏览器的CSS选择器

来自分类Dev

指南针变换混合

来自分类Dev

无法卸载指南针

来自分类Dev

确定指南针方向

来自分类Dev

DeviceOrientation指南针Android

来自分类Dev

MongoDB指南针超时

来自分类Dev

不能再用指南针了

来自分类Dev

指南针@for和迭代

来自分类Dev

指南针与WPF箭头