2013-07-11 67 views
5

我正在從薩斯移動到手寫筆,我有很多mixin,我通過一個代碼塊,可在mixin內訪問@content如何將一個代碼塊傳遞到一個函數或混入在手寫筆

例如...

@mixin respond-min($width) { 
    // If we're outputting for a fixed media query set... 
    @if $fix-mqs { 
     // ...and if we should apply these rules... 
     @if $fix-mqs >= $width { 
      // ...output the content the user gave us. 
      @content; 
     } 
    } 
    @else { 
     // Otherwise, output it using a regular media query 
     @media all and (min-width: $width) { 
      @content; 
     } 
    } 
} 

@include respond-min($mq-group2) { 
    & { 
     border: 1px solid green; 
    } 
} 

我想上面的代碼轉換爲手寫筆,但只要被我如何傳遞一個代碼塊到手寫筆沒有出現在混入我的主要問題有這個功能。

是否有替代解決方案?

任何幫助表示讚賞。

+0

你現在必須創建一個mixin,它作爲一個參數傳遞 – Ven

回答

6

這成爲可能與手寫筆的最新版本 - 0.41.0,上面的代碼可以寫在手寫筆這樣的:

respond-min($width) 
    // If we're outputting for a fixed media query set... 
    if $fix-mqs is defined 
    // ...and if we should apply these rules... 
    if $fix-mqs >= $width 
     // ...output the content the user gave us. 
     {block} 
    else 
    // Otherwise, output it using a regular media query 
    media = 'all and (min-width: %s)' % $width 
    @media media 
     {block} 

+respond-min($mq-group2) 
    border: 1px solid green 
+2

優秀!非常感謝你。我打算在不久的將來將BBC新聞從Sass轉移到Stylus上:-) – Integralist

0

值得注意的是,目前有關於將多個參數傳入@media查詢的問題。 mixin也不能用作選擇器。

相關問題