为什么image-path在scss中没有解决? [英] why image-path is not resolved in scss?
问题描述
在我的应用程序中,我有一个scss文件,由一个宝石,居住在我的应用程序项目文件夹中的gem文件夹外侧
in my app, I have a scss file, resulted from a gem, resident in the gem folder out side of my app project folder
,我有图像的路径正确,像这样:(从元素检查器在chrome复制)
in works just fine locally, I have the path to images correct, like this: (copied from element inspector at chrome)
media="all"
.social-share-button-twitter {
display: inline-block;
width: 16px;
height: 16px;
background: url("/assets/sprites/social-share-button.png") 0px -48px no-repeat;
}
但是当我部署到heroku时,我得到这个结果:
but, when I deploy to heroku, the image-path is not resolved, I get this result:
media="all"
.social-share-button-twitter {
display: inline-block;
width: 16px;
height: 16px;
background: url(image-path("sprites/social-share-button.png")) 0px -48px no-repeat;
}
注意上面的url,当然不会指向png图像。
notice the url above, of course it will not point to the png image.
这里是如何在scss文件中:
here is how its in the scss file:
.social-share-button-baidu { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button.png')) 0px 0px no-repeat }
任何想法为什么我在部署的应用程序中得到错误的路径?
Any idea why I get the wrong path at the deployed app ?
如何强制rails使用另一个scss文件而不是宝石文件夹?
我试图在application.css中设置另一个文件,但是rails继续使用gem文件夹中的文件。
How can I force rails to use another scss file instead of the file at the gem folder ? I tried to set another file in the application.css but, rails keep using the file at the gem folder.
任何想法?为什么它的工作在本地?
Any idea ? why its works fine locally ?
推荐答案
如果它是scss而不是指南针,文件夹与您的scss文件进行比较)
If it is scss and not compass then it would go like this (look at where you sprites folder is compared to your scss file)
.social-share-button-baidu
{
display:inline-block;
width: 16px;
height: 16px;
background: url(../sprites/social-share-button.png) 0px 0px no-repeat;
}
../会将您从一个文件夹中取出,文件夹从哪里?
../ takes you up out of one folder, can you see the sprites folder from there?
这篇关于为什么image-path在scss中没有解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!