2013-08-17 27 views
1

我不想用mixin來定義我的屬性。我想是建立@extend/@include東西之間的東西,像下面如何用@include sass做點什麼

的例子

文件=> structure.scss

.box{ 
    width:100px; 
    height:100px; 
} 

文件=> color.scss

@import 'structure.scss'; 
.box{ 
    @extend .box; 
    background: red; 
} 

輸出:

.box{ 
    width:100px; 
    height:100px; 
} 
.box{ 
    background: red; 
} 

我想不混入:

.box{ 
    width:100px; 
    height:100px; 
    background: red; 
} 
+1

爲什麼它需要是沒有混入? – cimmanon

回答

-1

沒有進口..

.bg-red { 
    background: red; 
} 
.box { 
    width:100px; 
    height:100px; 
    .bg-red; 
} 

.box { 
    width:100px; 
    height:100px; 
} 
.red-box { 
    background: red; 
    .box; 
} 

.square { 
    width:100px; 
    height:100px; 
} 
.bg-red { 
    background: red; 
} 

.red-box { 
    .square; 
    .bg-red; 
} 

它仍然是一個混合。順便說一句,這是LESS語法,SASS/SCSS語法應該是類似

或只使用OOCSS <div class="rounded red box"></div>

+0

在LESS中,'.box {.bg-red}'等同於在Sass中使用mixin。 – cimmanon

+0

他不僅無法使用mixin,他提出的語法比mixin更大更冗長。我看到的最接近的解決方案是編寫可以單獨使用的部分CSS,可以同時用作mixins,也可以用作oocss。 – Robert

相關問題