指南针给了我错误的精灵之路

Mar*_*sen 9 sass compass-sass

config rb正在运行默认值.文件夹结构也是默认的.

在我的scss文件中我做.

@import "icons/*.png";

@mixin sprite_css($name) {
@include icons-sprite($name);
height: icons-sprite-height($name);
width: icons-sprite-width($name);
display:block;
}


.btn {@include sprite_css(deltag);}  //deltag is the name of a png image in the sprite.
Run Code Online (Sandbox Code Playgroud)

在此之前,我在images文件夹下创建了一个文件夹,在这里称为图标我将所有的png文件放入其中.

生成的css代码如下所示.

.icons-sprite, .icons-deltag, .icons-deltag_grey, .icons-deltag_mouseover, .icons-facebook_del, .icons-faneblad, .icons-soegefelt, #container .btn, #container .btn_over {
background: url('/images/icons-s93e62b2fff.png') no-repeat;
}`
Run Code Online (Sandbox Code Playgroud)

注意背景路径设置没有图像文件夹前面的尾随点,所以放在stylesheets文件夹中的CSS文件现在在stylesheets文件夹中查找图像文件夹,显然文件没有加载.无论如何我似乎无法改变这一点.将config rb更改relative_assets = true为无效.

我希望css文件指向sprint.

background: url('../images/icons-s93e62b2fff.png') no-repeat; 
Run Code Online (Sandbox Code Playgroud)

这是正确的道路,我怎样才能做到这一点?

Bea*_*ith 4

config.rb每次运行 Compass 命令时都会加载Compass文件。如果正在运行,compass watch则必须退出该进程,然后再次启动它才能重新加载对config.rb文件的更改。