0

我有 CSS 文件

public/stylesheets/landing.css

使用标签时效果很好

<%= stylesheet_link_tag "/stylesheets/landing" %>

我也有这张图

public/images/1-hero-image.jpg

现在,在 css 文件中,我试图引用这个图像。

我尝试了以下变体:

background: url('1-hero-image.jpg');
background: url('/public/images/1-hero-image.jpg');
background: url('/images/1-hero-image.jpg');
background: url('images/1-hero-image.jpg');

它们似乎都不起作用。

如果您能提供任何帮助,我将不胜感激。

4

1 回答 1

1

background: url('/images/1-hero-image.jpg');在你的情况下就足够了。

最好用于 CSS 和 images 文件夹app/assets/

于 2019-02-27T16:58:47.087 回答