2012-10-18 81 views
1

有沒有辦法像下面這個例子那樣自動生成IE特定的文件?Compass/Sass自動生成IE css文件

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

這會生成兩個文件:

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


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

回答

0

你必須設置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; 
    } 
} 
+0

非ie特定的css將會在特定於ie的文件中輸出,不過:/ –

+0

因此,您創建了第二個混合,即opp osite並隱藏IE瀏覽器無法/不應該使用的CSS。 – cimmanon

+0

scss應該讓css可讀。讓我們按照https://github.com/nex3/sass/issues/241 –