2013-08-23 56 views
0

我使用Rails 2.3.5的工作,我有圖像,其中加入到名爲custom.css的CSS文件了public/images/圖片網址下的樣式表2.3

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

如何我可以讓這個閱讀裏面的公衆/圖像? 我都試過,但沒有奏效

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

也是這不起作用

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

有了資產路徑,你不應該在你的文件名之前需要'/ images /',對嗎? – kunalbhat

+0

它不能正常工作,並且我更新了我的問題 –

回答

0

兩個例子是正確的:

#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; 
} 
0

你可以嘗試使用IMAGE_PATH幫手?

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

+0

經過測試且不工作 –

0

有關使用此<%= asset_path 'NAV-bg.png' %>你將不得不file.css後增加.erb,它應該像yourfile。 css.erb