0

SCSSのミックスインを作成しています。引数に応じて、追加の値を追加できることを知りたいです。これは私が試したことです。すべてが機能しますが、@ if条件:

@mixin fontFace( $fontName, $path: "", $weight: normal, $style: none, $fileName: $fontName, $svg:0 ) {
    @font-face {
      font-family: $fontName;
        src: url("#{$path}#{$fileName}.eot");
        src: url("#{$path}#{$fileName}.eot?iefix") format("eot"), 
                 url("#{$path}#{$fileName}.woff") format("woff"),
                 url("#{$path}#{$fileName}.ttf") format("truetype")
                 @if $svg != 0 {
                    , url("#{$path}#{$fileName}.svg##{$fileName}") format("svg");
                 }else{
                    ;
                 }
      font-weight: $weight;
      font-style: $style;
    }
}
4

1 に答える 1

1

次はどうですか:

@mixin fontFace( $fontName, $path: "", $weight: normal, $style: none, $fileName: $fontName, $svg: false ) {
    $src: url("#{$path}#{$fileName}.eot?iefix") format("eot"), 
          url("#{$path}#{$fileName}.woff") format("woff"),
          url("#{$path}#{$fileName}.ttf") format("truetype");

    @if $svg == true {
        $src: $src, 
                url("#{$path}#{$fileName}.svg##{$fileName}") format("svg");
    }

    @font-face {
        font-family: $fontName;
        src: url("#{$path}#{$fileName}.eot");
        src: $src;
        font-weight: $weight;
        font-style: $style;
    }
}
于 2012-06-25T11:51:58.993 に答える