Sass:将默认值设置为变量

时间:2014-01-23 09:27:17

标签: sass

写这个的正确方法是什么?

@mixin image-bg($bg-url, $full-page: false)
  background-repeat: no-repeat
  background-position: center
  background-image: asset-url($bg-url) 
  background-attachment: fixed
  @if $fullpage
    -webkit-background-size: cover
    -moz-background-size: cover
    -o-background-size: cover
    background-size: cover 

我想将$ full-page变量传递给@mixin。当用户将$ full-page设置为true时,它将使用cover语句。如果未给出或设置为false,则不会使用cover语句

1 个答案:

答案 0 :(得分:1)

你的代码看起来是正确的,除了一个小错误:

@if $fullpage

您的变量名为$full-page,而不是$fullpage

相关问题