【问题标题】:Compass / Sass automatic generate IE css filesCompass/Sass 自动生成 IE css 文件
【发布时间】:2012-10-18 22:04:57
【问题描述】:

有没有办法像下面的示例那样自动生成 IE 特定文件?

   /* content.scss */
.box {
    color:red;
    .ie7 & {
        color:green;
    }
}

这会生成两个文件:

/* content.css */
.box {
  color: red;
}


/* ie7.css */
.ie7 .box {
  color: green;
}

【问题讨论】:

    标签: compass-sass sass


    【解决方案1】:

    您必须设置 2 个不同的 Sass 文件,但您可以使用自定义 mixin 来完成:

    http://jakearchibald.github.com/sass-ie/

    $old-ie: false !default;
    
    @mixin old-ie {
        // Only use this content if we're dealing with old IE
        @if $old-ie {
            @content;
        }
    }
    
    .test {
    
        float: left;
        width: 70%;
    
        @include old-ie {
            // These hacks won't appear in the normal stylesheet
            display: inline;
            zoom: 1;
            whatever-ie-needs: le-sigh;
        }
    }
    

    【讨论】:

    • 非 ie 特定的 css 将在 ie 特定的文件中输出,虽然:/
    • 所以你制作了第二个相反的 mixin,并隐藏了 IE 不能/不应该使用的 CSS。
    • scss 应该使 css 可读。让我们关注github.com/nex3/sass/issues/241
    • 然后呢? Sass 已经有了做你想做的事情的工具(@if/@content 指令),因为 nex3 在那个讨论中一遍又一遍地重复。使用 not-for-ie/ie-only mixins 阻止您的样式并不比线程中建议的任何内容更具可读性。
    猜你喜欢
    • 2012-12-20
    • 2013-11-10
    • 1970-01-01
    • 2020-04-09
    • 2015-11-19
    • 2019-12-08
    • 1970-01-01
    • 2017-06-26
    • 2021-07-26
    相关资源
    最近更新 更多