0

I am working with Rails 2.3.5 and I have images in public/images/ which are added into css file named as custom.css

#cssmenu ul {
  background: url(nav-bg.png) repeat-x 0px 4px;
  height: 69px;
}

How can i make this read the image which in inside public/images ? I have tried this but it did not work

#cssmenu ul {
  background: url(<%= asset_path '/images/nav-bg.png' %>) repeat-x 0px 4px;
  height: 69px;
}

also this does not work

#cssmenu ul {
      background: url(<%= asset_path 'nav-bg.png' %>) repeat-x 0px 4px;
      height: 69px;
    }
4

3 回答 3

0

Can you try using the image_path helper?

background: url(image_path('nav-bg.png'));

于 2013-08-23T19:42:02.600 回答
0

Both examples are correct:

#cssmenu ul {
  background: url(../images/nav-bg.png) repeat-x 0px 4px;
  height: 69px;
}

#cssmenu ul {
  background: url(/images/nav-bg.png) repeat-x 0px 4px;
  height: 69px;
}
于 2013-08-23T19:55:54.310 回答
0

For using this <%= asset_path 'nav-bg.png' %> you will have to add .erb after file.css and it should look like yourfile.css.erb

于 2013-08-24T07:24:37.083 回答