2015-07-03 32 views
2

我想將所有媒體查詢放入一個對象中,然後遍歷它們。它運作良好,但手寫筆強制我的輸出在括號內。 我的問題是有辦法刪除括號和引號?手寫筆迭代字符串

我的代碼:

$maxBreakpoints = { 
    "0": 'and (min-width: 1701px) and (max-width: 1920px)', 
    "1": 'and (min-width: 1440px) and (max-width: 1700px)', 
    "2": 'and (min-width: 1280px) and (max-width: 1439px)', 
    "3": 'and (min-width: 1024px) and (max-width: 1023px)' 
} 

$_resolution = { 
    "0": 1920, 
    "1": 1440, 
    "2": 1280, 
    "3": 1024 
} 

for $i, $resolution in $maxBreakpoints 

    @media all $resolution 

而且這段代碼的輸出是:

@media all ('and (min-width: 1440px) and (max-width: 1700px)') 

回答

1

你需要移動all到字符串:

$maxBreakpoints = { 
    "0": 'all and (min-width: 1701px) and (max-width: 1920px)', 
    "1": 'all and (min-width: 1440px) and (max-width: 1700px)', 
    "2": 'all and (min-width: 1280px) and (max-width: 1439px)', 
    "3": 'all and (min-width: 1024px) and (max-width: 1023px)' 
} 

$_resolution = { 
    "0": 1920, 
    "1": 1440, 
    "2": 1280, 
    "3": 1024 
} 

for $i, $resolution in $maxBreakpoints 

    @media $resolution