2011-07-29 41 views
2

我想導入.less文件並在我的主less文件中添加一些背景圖像。該代碼是(客戶端):LessCss導入失敗,url和錨點

@import "child"; 

.image{ 
    background-image:url("image.png"); 
} 

的較少文件從URL稱爲:

http://localhost/mywebsite#/root. 

少編譯進口:

http://localhost/mywebsite#/root//localhost/mywebsite#/root//mywebsite/child.less 

背景圖像的URL :

http://localhost/mywebsite#/root//localhost/mywebsite#/root//mywebsite/image.png 
+0

什麼在你的URL哈希邦(#)是? –

+0

你使用什麼瀏覽器? –

+0

我正在使用javascriptmvc框架,因此導航是在客戶端執行的。我使用Chrome或Firefox;問題是一樣的! – bichehype

回答

0

沒有活的ex充足的,這將很難找到你的代碼加載的路徑。

確保您加載使用正確的路徑文件:

<link rel="stylesheet/less" type="text/css" href="styles.less"> 

所有.LESS CSS值將裝載相對於該URL。

您也可以嘗試使用:

.image{ 
    background-image:url("/image.png"); 
} 

如果一切都失敗了,你總是可以使用絕對路徑圖像

.image{ 
    background-image:url("http://localhost/mywebsite#/root/image.png"); 
}