【问题标题】:Add Background Image to .scss File in Ruby on Rails在 Ruby on Rails 中将背景图像添加到 .scss 文件
【发布时间】:2014-04-28 22:50:39
【问题描述】:

我试图将背景图像添加到画布(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'

任何帮助都会很棒!谢谢

【问题讨论】:

  • 那你如何使用你的变量呢?

标签: ruby-on-rails sass


【解决方案1】:

试试这个sn-p的代码..

@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;
}

【讨论】:

    猜你喜欢
    • 2012-02-19
    • 1970-01-01
    • 2018-11-26
    • 2010-12-21
    • 1970-01-01
    • 2018-03-16
    • 2014-02-03
    • 2013-12-06
    • 2015-01-11
    相关资源
    最近更新 更多