在Ruby on Rails中将背景图像添加到.scss文件中

时间:2014-04-28 14:47:48

标签: ruby-on-rails sass

我试图将背景图片添加到画布(Zurb Foundation 5),但是当我这样做时出错:

# Located in this file: foundation_and_overrides.scss
$off-canvas-bg: #fff url(../assets/img/canvas-bg.jpg) no-repeat;

显示错误:

$color: (white url(../assets/img/canvas-bg.jpg) no-repeat) is not a color for `scale-color'

任何帮助都会很棒!感谢

1 个答案:

答案 0 :(得分:0)

试试这段代码..

@mixin background($imgpath,$position:0 0,$repeat: no-repeat) {
    background: {
        image: url($imgpath);
        position: $position;
        repeat: $repeat;
    }
}
.testing {
    @include background('/my/img/path.png');
}

然后输出:

.testing {
  background-image: url("/my/img/path.png");
  background-position: 0 0;
  background-repeat: no-repeat;
}