繁体   English   中英

背景图片Heroku Rails无法正常工作

[英]background image heroku rails not working

我有一个基本的Rails站点的背景图像,我可以正常工作,但是当我将其推到heroku时,出现了以下错误

Failed to load resource: the server responded with a status of 404 (Not Found) http://young-oasis-2855.herokuapp.com/assets/joy.jpg

这是我的css文件中的代码

body {
  background: url(/assets/joy.jpg) no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

我还上传了其他几张照片,并且工作正常,有人知道为什么这在heroku上不起作用,但仍在本地工作吗?

尝试使用image-url('joy.jpg')代替url

这个答案可能会为您提供更多信息: 如何在Rails 4中引用CSS中的图像

同样,我使用了这样的CSS属性。

background-image:url('joy.jpg');

我也遇到了这个错误,我通过以下方法解决了它:

Production.rb

config.cache_classes = true
config.assets.compile = true

背景图片:url(assets / hero_bg_2.jpg)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM