gpt4 book ai didi

css - rails : How to set a background image in rails from css?

转载 作者:数据小太阳 更新时间:2023-10-29 09:11:25 28 4
gpt4 key购买 nike

我使用的是 Rails 3.2,我必须为其中一个页面设置背景,我尝试了很多方法,但都没有成功,所以寻求一些好的帮助。我试过了

background: url(<%= asset_path 'background.jpg' %>)

background: url("public/background.jpg");

background-image:url('/assets/images/background.jpg')

但没有任何效果。请帮助我。

最佳答案

在你的 CSS 中:

background-image: url(background.jpg);

background-image: url(/assets/background.jpg);

environments/production.rb 中:

# Disable Rails's static asset server (Apache or nginx will already do this)  
config.serve_static_assets = false

# Compress JavaScripts and CSS
config.assets.compress = true

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false

# Generate digests for assets URLs
config.assets.digest = true

关于css - rails : How to set a background image in rails from css?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18100650/

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