grabury grabury - 1 year ago 59
CSS Question

Why is my background image not displaying?

I have a

file in my rails app.

I want to display a background image so I added the line with a rails helper method:

background: image-url('bnr-01.jpg') no-repeat;

The image is not displayed.

I get the error
'Invalid property valid'

The css that's generated is:

background: image-url(bnr-01.jpg) no-repeat;

Answer Source

Since you are saying it is css.erb file you should use the rails helper as,

Use <%= asset_path 'bnr-01.jpg' %> rails helper

background-image: url(<%= asset_path 'bnr-01.jpg' %>)

You can also use,


You used image-url which is wrong use, image_url

Here is the reference

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download