簡體   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