2016-03-02 53 views
1
@mixin fullwidth($breakpoint,$grid-size) 
{ 
    $varGridsize:col-#{$grid-size}; 
    @media only screen and (max-width: #{$breakpoint}px) { 
     [class ^="$varGridsize"]{width:100%;} 
    } 
} 

我們如何能夠在這個[class ^="$varGridsize"]選擇ADDD一個變量是把它當作一個字符串,並返回在CSS文件中的字符串作爲

[class^="$varGridsize"] { 
    width: 100%; 
} 

回答

2

簡單包裝$varGridsize#{},如:

@mixin fullwidth($breakpoint,$grid-size){ 
    $varGridsize:col-#{$grid-size}; 
    @media only screen and (max-width: #{$breakpoint}px){ 
     [class ^="#{$varGridsize}"]{width:100%;} 
    } 
} 
+0

它被稱爲插值http://sass-lang.com/documentation/file.SASS_REFERENCE.html#Interpolation_____ – Logus

相關問題