这个在config.rb文件中有提到
images_dir = "images"
我在 images 文件夹中的元素中使用 2 个文件夹存放图像
images
images/background/
images/content/
如果 images/background/
文件夹中有任何图像,那么我应该如何在 css background
和 Sass 变量中添加图像路径?
$header-img: "sass.gif";
和
background-image: url('sass.gif?1327592426');
以及如何从每个背景图像中删除这个自动生成的 ?1327592426
?
最佳答案
您应该使用image-url
URL helper .它“生成相对于元素图像目录找到的 Assets 的路径”,您在 config.rb
中定义了该路径。也可以设置第三个参数$cache-buster
为false来移除生成的?1327592426
萨斯:
// image-url arguments:
// $path: path relative to images directory in config.rb
// $path-only: if true, will cause only the path to be returned instead of a `url()` function
// $cache-buster: When set to `false` no cache buster will be used (i.e. `?313420982`)
$header-img: image-url('background/sass.gif', false, false)
background-image: $header-img
生成的 CSS:
background-image: url('images/background/sass.gif')
关于css - Sass 和 Compass 中的背景图片路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9021306/