2015-05-26 21 views
1

幾個css合併時需要將相對路徑轉換爲絕對路徑。params和php realpath的路徑

其中一個步驟 - 獲得實際路徑。

以其CSS有自引導:

結果後
@font-face { 
    font-family: 'Glyphicons Halflings'; 
    src: url('../fonts/glyphicons-halflings-regular.eot'); 
    src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), 
     url('../fonts/glyphicons-halflings-regular.woff') format('woff'), 
     url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), 
     url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg'); 
} 

真實路徑

@font-face { 
    font-family: "Glyphicons Halflings"; 
    src: url("/somepath/fonts/glyphicons-halflings-regular.eot"); 
    src: url("") format("embedded-opentype"), 
     url("/somepath/fonts/glyphicons-halflings-regular.woff") format("woff"), 
     url("/somepath/fonts/glyphicons-halflings-regular.ttf") format("truetype"), 
     url("") format("svg"); 
} 

對於使用參數路徑返回

如何獲得帶參數的路徑的實際路徑和保存參數

回答

0

你是說php的函數「realpath」? 如果是這種情況,它不是用於url,而是用於文件系統路徑。

如果你想爲你的字體使用絕對路徑,它應該以「/」開頭。 ie:url(「/ css/fonts/glyphicons-whateveryoulike.ttf」)

開頭的「/」是你網站目錄的根目錄。

+0

步驟的CSS合併〜:如果_preg_math_all_(url) - >排除_substr_(協議和數據:) - >實時路徑 - >獲取Webpath – lifecom