问题描述
我在3.2.1上,使用sass-rails-3.2.4和sass-3.1.15 ...
I am on 3.2.1, with sass-rails-3.2.4 and sass-3.1.15...
资产管道的文档说:
asset-url("rails.png", image) becomes url(/assets/rails.png)
image-url("rails.png") becomes url(/assets/rails.png)
...
所以我制作了以下文件:
So I made the following file:
# app/assets/stylesheets/public/omg.css.sass
body
background: asset-url('snake.gif', image)
#lol
background: image-url('snake.gif')
当我访问localhost:3000/assets/public/omg.css时,我得到:
and when I visit localhost:3000/assets/public/omg.css I get:
body {
background: asset-url("snake.gif", image); }
#lol {
background: image-url("snake.gif"); }
...我还尝试将文件更改为omg.css.scss并将语法更改为:
... I also tried changing the file to omg.css.scss and changed the syntax to:
# app/assets/stylesheets/public/omg.css.scss
body {
background: asset-url('snake.gif', image);
}
#lol {
background: image-url('snake.gif');
}
但是得到相同的结果...没有人知道为什么这些助手不起作用吗?
but get the same results... does anyone have any idea why these helpers are not working?
推荐答案
尽管文档说了什么,但Rails 3.2.6中的默认选项似乎使您可以在CSS中使用更少的路径信息来工作.例如. ../app/assets/images/rails.png
是example.css.scss文件中的引用,类似于:
Despite what the documentation says, it seems the default options in rails 3.2.6 allow you to just make things work with even less path information in your CSS.E.g. ../app/assets/images/rails.png
is references in your example.css.scss file with something like:
background: white url(rails.png) repeat-y;
据我所知,您没有将image-url
或asset-url
包含在您的scs中,只是普通的url(your_image.png)
.这些文档似乎只是对它在后台执行操作的一种解释.
You don't include the image-url
or asset-url
into your scss (as far as I know), just plain url(your_image.png)
. That bit of documentation appears to be just an explanation of what it is doing in the background.
这篇关于sass-rails助手"image-url","asset-url"在rails 3.2.1中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!