热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

背景图像路径的Sass和指南针。-BackgroundimagespathinSassandCompass

Thisismentionedinconfig.rbfile配置中提到了这一点。rb文件images_dirimagesIuse2folderforimage

This is mentioned in config.rb file

配置中提到了这一点。rb文件

images_dir = "images"

I use 2 folder for images in my projects inside images folder

我在images文件夹里的项目中使用了两个文件夹

images
images/background/
images/content/

If any images is inside images/background/ folder then how i should add the path for image in css background and Sass variables?

如果图像/背景/文件夹中有图像,那么我应该如何在css背景和Sass变量中添加图像路径?

$header-img: "sass.gif"; 

and

background-image: url('sass.gif?1327592426');

And how to get rid of this auto generated ?1327592426 from each background image?

如何摆脱这个自动生成的?1327592426从每个背景图像?

1 个解决方案

#1


34  

You should use the image-url URL helper. It "generates a path to an asset found relative to the project's images directory" which you defined in your config.rb. You can also set the third parameter $cache-buster to false to remove the generated ?1327592426

您应该使用image-url URL帮助程序。它“生成相对于项目映像目录找到的资产的路径”,您在config.rb中定义了这个目录。您还可以将第三个参数$cache-buster设置为false,以删除生成的?1327592426

Sass:

萨斯:

// 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

Generated CSS:

生成CSS:

background-image: url('images/background/sass.gif')

推荐阅读
author-avatar
迷茫的路人甲-
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有