sass - compass 为我提供了通往 Sprite 的错误路径

标签 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.

在此之前,我在图像文件夹下创建了一个文件夹,称为图标
在这里,我将所有的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;
}`

请注意,设置的背景路径没有在images文件夹前面的尾随点,因此放置在stylesheets文件夹中的CSSfile现在正在stylesheets文件夹内寻找image文件夹,因此显然文件未加载。无论如何,我似乎无法改变这一点。将config rb更改为relative_assets = true不起作用。

我希望css文件将sprint指向。
background: url('../images/icons-s93e62b2fff.png') no-repeat; 

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

最佳答案

每次您运行Compass命令时,都会加载Compass config.rb文件。如果您正在运行compass watch,则必须退出该过程,然后再次启动它,以便将更改重新加载到config.rb文件。

关于sass - compass 为我提供了通往 Sprite 的错误路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12422080/

相关文章:

sass - Meteor.js 和 SCSS/指南针

css - 如何: get new line between two spans?

css - SASS : making underscore file names actually create css files

ruby - 如何在 Windows 7 上正确安装 Compass?

ruby-on-rails - 更新破坏 Sass 框架 - 不兼容的单元 : 'px' and 'em'

ruby-on-rails - SASS中每隔一行的背景色

css - 找不到 laravel mix sass 图像/哈希

css - 使用第 n 个子值作为 SASS 变量

css - 在 SCSS 中制作 Sprite 的最佳方式?

css - SASS/SCSS 对象键值循环