【发布时间】:2012-07-09 03:07:45
【问题描述】:
我已经尝试了许多不同的方法,但都没有奏效,我在这里遗漏了什么吗?
这是我尝试过的......
th a.asc {
background-image: url(up_arrow.gif);
}
th a.desc {
background-image: url(down_arrow.gif);
}
和
th a.asc {
background-image: url("assets/up_arrow.gif");
}
th a.desc {
background-image: url("assets/down_arrow.gif");
}
和
th a.asc {
background-image: url(assets/up_arrow.gif);
}
th a.desc {
background-image: url(assets/down_arrow.gif);
}
和
th a.asc {
background-image: url(<%= asset_path "up_arrow.gif" %>);
}
th a.desc {
background-image: url(<%= asset_path "down_arrow.gif" %>);
}
还有……
th a.asc {
background-image: asset-url("up_arrow.gif", image);
}
th a.desc {
background-image: asset-url("down_arrow.gif", image);
}
还有更多。
我已重命名文件 application.css、application.css.scss、application.css.erb、application.scc.scss.erb、index.css、index.css.scss、index.css.erb
我已阅读此...http://edgeguides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets 和 404 when displaying background image in CSS with rails 3.2 和 Rails 3.1 serving images from vendor/assets/images 和 Rails 3.1 and Image Assets 以及来自 stackoverflow 的其他页面。
但我的图像没有出现。它们位于app/assets/images 目录中。我已经双重检查和三重检查,是的,它们在那个位置。我转到 Google Chrome 中的检查元素,当我单击图像链接时,它会显示损坏的链接图像。
【问题讨论】:
-
你的css文件在哪个目录?
-
app/assets/stylesheets -
这是在本地开发还是在生产中?
-
开发。我有另一个使用
background: #f0f0f0 url('/assets/bg-body.gif') top left repeat-y;的应用程序没有问题。 -
把 url 改成 '../images/down_arrow.gif' 试试
标签: css ruby-on-rails ruby sass