我所试图做的是创造价值
- 循环通过地图$断点,
- 拉出最小值为每个断点,
- 计算基于每一个EM值,
- 然后使用这些对于这个代码需要商品的全球地图$ MS-范围
可变的,看起来像这样:
$ms-range:
1.2 20em,
1.333 30em,
1.618 40em,
1.8 50em,
2 60em;
我不能让函数返回我想要的格式。也许地图延伸?!我不知道。我需要一位SASS大师!
SASS:
$breakpoints: (s: (320, 479), sm: (480, 767), m: (768, 1023), l: (1024, 1439), xl: (1440, null));
@function returnThatMap() {
@each $name, $values in $breakpoints {
@for $i from 1 through length($name) {
$min: nth($values, 1);
// if the last one
@if ($i == length($name)) {
@return 'calc($i * 1.2) $min/16 * 1em'
}
// if not the last one
@else {
@return 'calc($i * 1.2) $min/16 * 1em',
}
}
}
}
$ms-range : returnThatMap() ;
// OUTPUT FORMAT NEEDED below!! (dummy numbers, but correct syntax - ie. number ' ' [number]em,number ' ' [number]em, number ' ' [number]em;)
// $ms-range:
// 1.2 20em,
// 1.333 30em,
// 1.618 40em,
// 1.8 50em,
// 2 60em;
SASSMEISTER LINK: http://www.sassmeister.com/gist/700f0721fd7940c84435cb1b5210f5d7
惊人的工作!谢谢你的帮助。代码中的评论非常感谢。 –
没问题!乐于帮助 :) –