Sass mixin或函数返回mixins

时间:2016-08-05 12:55:38

标签: css3 sass mixins

我想编写返回mixin的函数/ mixins。例如,我有这个mixin:



@mixin generate-offsets-from-map($class-slug,$type,$from, $to, $step) {
    $i: $from;
    @while $i <= $to {
        @if ($type == "vertical") {
            .#{$class-slug}-#{$type}-#{$i}, @mixin {$class-slug}-#{$type}-#{$i} { 
                padding: {
                    top: $i * 1px;
                    bottom: $i * 1px;
                }
            }
        
        } @else if ($type == "horizontal") {
            .#{$class-slug}-#{$type}-#{$i}, %#{$class-slug}-#{$type}-#{$i} {
                padding: {
                    left: $i * 1px;
                    right: $i * 1px;
                }
            }
        }
        
        $i: $i + $step;
    }
}
@include generate-offsets-from-map(offset,vertical,10,100,1);
&#13;
&#13;
&#13;

我生成了offset-vertical / horizintal-1/100类,但我希望生成@mixin offset-vertical / horizintal-1 / 100.

1 个答案:

答案 0 :(得分:0)

可能无法在控制指令或其他mixin中定义Mixins。