在CSS中使用rails 3.2显示背景图像时使用404 [英] 404 when displaying background image in CSS with rails 3.2

查看:165
本文介绍了在CSS中使用rails 3.2显示背景图像时使用404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我手动添加assets / images目录在rails 3.2应用程序,并添加了图像background.png。当引用来自css的图片

I manually added assets/images directory in a rails 3.2 app and added the image background.png . When referring to the image from css

background:url(assets / background.png)no-repeat;

我得到一个404,但是资产/样式表和资产/ javascripts正在显示。

I am getting a 404 , however assets/stylesheets and assets/javascripts are showing up.

* UPDATE

它似乎恢复为显式调用样式表ie

it appears as if I revert back to explicitly calling the stylesheet ie

<%=stylesheet_link_tag "home.css"%> 

而不是

<%=stylesheet_link_tag "application" %>

背景图片重新正确

推荐答案

该url是相对于样式表的位置。您可能希望 url(../ assets / background.png)从样式表或 url(/ assets / background .png)从根开始。

That url is relative to where the style sheet is. You probably want either url(../assets/background.png) to go up a level from your style sheet or url(/assets/background.png) to go from the root.

这篇关于在CSS中使用rails 3.2显示背景图像时使用404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆