Compass adding leading slash when generating sprite

大兔子大兔子 提交于 2019-12-20 07:07:38

问题


I have just generated a sprite with compass, but for some reason it is adding a leading slash in the generated class url. Is it possible to override this or is it something I have wrong in my config.rb?

Thanks for any help.

Joe

config.rb >

http_path = "/"
css_dir = "/"
sass_dir = "/"
images_dir = "img"
javascripts_dir = "js"

sass >

@import "spr/*.png";
@include all-spr-sprites;

generated css >

.spr-sprite, .spr-female, .spr-male {
  background: url('/img/spr-s88dfc99cac.png') no-repeat;
}

回答1:


Appologies, as soon as I posted the question I found the answer to another question here ...

Compass throwing in forward slash in front of images when making sprites

ANSWER:

By default, compass uses absolute paths for all assets.

To change this behaviour, add this line to your config.rb:

relative_assets = true

Otherwise, you could also change the 'http_path' option to point to where your project sites on your deployment server.



来源:https://stackoverflow.com/questions/15228243/compass-adding-leading-slash-when-generating-sprite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!