Adding a background image in Ruby on Rails 2 in CSS

前端 未结 6 948
野趣味
野趣味 2020-12-07 19:08

I generated a scaffold in ruby and I want to insert a background image to every page on the site but Im not sure what the link to the image should be.

my image is

6条回答
  •  无人及你
    2020-12-07 19:48

    In Rails 3.1, the path will actually be `/assets/dep.jpg':

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

    If you convert your scaffold.css file to a Sass file (rename to scaffold.css.scss) then you can use the helper:

    background-image: image-url("dep.jpg");
    

提交回复
热议问题