如何设置背景图像在rails从css? [英] How to set a background image in rails from css?
本文介绍了如何设置背景图像在rails从css?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用rails 3.2,我必须设置一个页面的背景,我已经尝试了很多方式,没有什么是正确的,所以寻找一些很好的帮助。我尝试过
I am using rails 3.2 and i have to set a background for one of the page and i have tried many ways and nothing went right, so looking for some good help. I have tried
background: url(<%= asset_path 'background.jpg' %>)
background: url("public/background.jpg");
background-image:url('/assets/images/background.jpg')
$ b b
没有什么工作。请帮助我。
and nothing worked. Please help me.
推荐答案
在您的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
这篇关于如何设置背景图像在rails从css?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文