Sass和Bourbon的IE条件注释 [英] IE conditional comments with Sass and Bourbon

查看:595
本文介绍了Sass和Bourbon的IE条件注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为不同的浏览器提供不同的字型(请参阅这个问题)。


$ b



这里是我到目前为止:

 <! -  [if IE]> - > 
@include font-face(myicons,myicons,$ weight:normal,$ style:normal,
$ asset-pipeline:false);
<![endif] - >
<! - [if!IE]> - >
@include font-face(myicons,myicons,$ weight:normal,$ style:normal,
$ asset-pipeline:true);
<![endif] - >


解决方案

这个问题在sass范围之外,一个预处理器,并且没有关于浏览器的线索。
也是不同浏览器的外部css范围决定条件。



你可以添加一个ie8类到像html5样板的html然后使用css规则来激活字体。

  body {
@include font-face(myicons,myicons $ weight:normal,$ style:normal,$ asset-pipeline:false);

.ie8& {
@include font-face(myicons,myicons,$ weight:normal,$ style:normal,$ asset-pipeline:true);
}
}

和html文件

 <! -  [if IE 8]> < html class =ie8> <![endif]  - > 
<! - [if gt IE 8]><! - > < html> <! - <![endif] - >


I want to serve different fonts to different browsers (see this question).

Is there a slick way to do this with Sass/Bourbon?

Here's what I have so far:

<!--[if IE]> -->
@include font-face("myicons", "myicons", $weight: normal, $style: normal,
                   $asset-pipeline: false);
<![endif]-->
<!--[if !IE]> -->
@include font-face("myicons", "myicons", $weight: normal, $style: normal,
                   $asset-pipeline: true);
<![endif]-->

解决方案

This problem it's outside the sass scope, because is just a pre processor, and doesn't have a clue about the browser. Also is outside css scope deciding conditions for different browsers.

You could do this adding a ie8 class to the html like html5 boilerplate does and then use a css rule to activate the font.

body {
  @include font-face("myicons", "myicons", $weight: normal, $style: normal, $asset-pipeline: false);

  .ie8 & {
    @include font-face("myicons", "myicons", $weight: normal, $style: normal, $asset-pipeline: true);
  }
}

and in html file

<!--[if IE 8]>         <html class="ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html>         <!--<![endif]-->

这篇关于Sass和Bourbon的IE条件注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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