在使用compass创建精灵图时,由于主精灵图像在screen.css中的路径出现错误,导致我无法看到该图像。
我的scss代码如下:
@import "compass";
@import "spr/*.png";
h1 { @include spr-sprite("car"); height:50px; width:50px; }
我的精灵图 CSS 输出
.spr-sprite, h1 { background: url('/images/spr-sa37328aec0.png') no-repeat; }
h1 { background-position: 0 -147px;
height: 50px;
width: 50px;
overflow: hidden;
text-align: left;
}
您可以看到,背景图片的路径应该以
../
开头,而不是直接使用/images/
。这会造成问题。
我的图片文件夹路径:images
------spr
---*.png
sass
-----screen.scss
css
---screen.css
我的config.rb代码如下
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "stylesheets"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"
我对Sass和Compass都很新,可能会错过一些代码。请帮我找出来。 非常感谢回答者提供的任何帮助。
config.rb
文件。在 配置选项 中设置的某些内容与您的项目结构不符。 - steveax