如何使用罗盘内联图像助手与不是相对的图像网址? [英] How can I use compass inline-image helper with an image url that is not relative?
问题描述
问题
如何使用指南针 inline-image helper ,图片网址不是相对的图片网址?
< h2> config.rb
relative_assets = false
我也尝试完全注释掉
此代码适用
hdr-main.png 位于本地服务器上的 / test / images / 中。
.test {
$ image:hdr-main.png;
background:inline-image($ image);
}
此代码
.test {
$ image:http://i.cdn.turner.com/cnn/.e/img/ 3.0 / global / header / hdr-main.png;
background:inline-image($ image);
}
.test {
$ image:http://i.cdn.turner.com/cnn/.e/img/ 3.0 / global / header / hdr-main.png;
background:inline-image($ image);
}
显示此错误
Compass无法编译项目中的一个或多个文件:
文件未找到或无法读取:/ Users / myname / test / images / http:// i .cdn.turner.com / cnn / .e / img / 3.0 / global / header / hdr-main.png
我不完全确定是什么问题,因为你没有真正提出问题。你有工作代码,我假设你正在渲染一个生产样式表。
你应该留下 $ image: hdr-main.png
as-is,然后使用config.rb将 http_images_path
设置为 http:// i .cdn.turner.com / cnn / .e / img / 3.0 / global / header /
。
这与将环境
设置为生产相结合。
if environment = =:production
http_images_path =http://i.cdn.turner.com/cnn/.e/img/3.0/global/header/
end
然后您可以使用以下
建立CSS:
compass compile -e production
同样,这是假设,因为上面没有一个明确的问题。如果这不是您需要的,请提出具体问题。
Problem
How can I use compass inline-image helper with an image url that is not relative?
config.rb
relative_assets = false
I also tried commenting that out completely
This code works
hdr-main.png lives in the /test/images/ on my local Server.
.test{ $image:"hdr-main.png"; background: inline-image($image); }
This code does not work
.test{ $image:"http://i.cdn.turner.com/cnn/.e/img/3.0/global/header/hdr-main.png"; background: inline-image($image); }
Displays this error
Compass was unable to compile one or more files in the project: File not found or cannot be read: /Users/myname/test/images/http://i.cdn.turner.com/cnn/.e/img/3.0/global/header/hdr-main.png
解决方案I'm not entirely sure what the issue is since you haven't actually asked a question. You have working code and I'm assuming you're trying to render a production stylesheet as well.
You should probably leave
$image: "hdr-main.png"
as-is then use config.rb to set yourhttp_images_path
tohttp://i.cdn.turner.com/cnn/.e/img/3.0/global/header/
.You'll want to probably use this in conjunction with setting the
environment
to production.if environment == :production http_images_path = "http://i.cdn.turner.com/cnn/.e/img/3.0/global/header/" end
then you'd build your CSS with the following
compass compile -e production
Again, this is assumption since there isn't a clear question posted above. If this isn't what you need, please ask a specific question.
这篇关于如何使用罗盘内联图像助手与不是相对的图像网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!