Css background image not working

Hello,
I’m trying to set the background of a page to an image I have in the
assets/images folder in my rails app.

However, for the life of me I cannot get it to work. When I open up and
inspect the element I keep seeing in the resources that the file cannot
be
found with a red “!” next to the image.

I have tried different paths still no avail…

…/images.bg.png
./images.bg.png
assets/images.bg.png

In my static_pages.css.scss I have

body {
background: url(/images/bg.png);

}

Figured it out!

Simply added

background: url(bg.png);

1 Like

If you prefer use scss with assets pipeline its better use following
sintax:
background: image-url(bg.png);

More about it you can read in RG:
http://guides.rubyonrails.org/asset_pipeline.html
2.2.2 CSS and Sass

1 Like

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs