gpt4 book ai didi

CSS 背景图片在 Heroku 中不显示

转载 作者:行者123 更新时间:2023-11-28 11:30:43 25 4
gpt4 key购买 nike

我已经在 SO 和其他帮助网站上阅读了大量关于这个问题的帖子,但到目前为止没有任何帮助。我的 CSS 中有图像显示在我的 localhost 上,但当我将我的应用程序推送到 Heroku 时却没有。

这是一个图像示例:

.hero-000 {
width: 102%;
background: url(hero-000.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

根据其他帖子的建议,我已将此添加到我的 application.rb:

config.assets.initialize_on_precompile = false

我还将此添加到我的 production.rb 中:

  config.serve_static_files = true
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
config.assets.compile = true
config.assets.digest = true

然后我按照 Heroku 网站上的步骤预编译 Assets here .

我真的不知道从这里该何去何从,所以感谢您的帮助。

最佳答案

我遇到了同样的问题,我用帮助解决了。在你的 CSS 上试试这个:

background-image: image-url("hero-000.jpg");

关于CSS 背景图片在 Heroku 中不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37338035/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com