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/