2013-03-15 116 views
0
<i class="icon-search"></i> 

試圖把上述行放在谷歌應用程序引擎。顯然,它不起作用,因爲我沒有將圖像文件鏈接到app.yaml文件。 app.yaml文件已經有以下代碼:如何使用twitter引導程序圖標與谷歌應用程序引擎?

- url: /static/images/(.*\.(gif|ico|jpeg|jpg|png)) 
    static_files: static/images/\1 
    upload: static/images/(.*\.(gif|ico|jpeg|jpg|png)) 

我應該怎麼做才能使用Twitter Bootstrap圖標?

回答

3

您所要做的就是正確指出Bootstrap附帶的兩個精靈圖像在哪裏。

如果使用小於發現在variables.less這些行:

@iconSpritePath:   "../img/glyphicons-halflings.png"; 
@iconWhiteSpritePath:  "../img/glyphicons-halflings-white.png"; 

,並改變他們是這樣的:

@iconSpritePath:   "/static/images/glyphicons-halflings.png"; 
@iconWhiteSpritePath:  "/static/images/glyphicons-halflings-white.png"; 

如果這些圖像位於static/images目錄。

否則,如果您使用的是引導的CSS版本,然後就找到這些圖像的引用,並把正確的路徑:

background-image: url("../img/glyphicons-halflings.png"); 
... 
background-image: url("../img/glyphicons-halflings-white.png"); 
+0

我在哪裏放@iconSpritePath?我正在使用整個揹包。我應該將圖像移動到靜態/圖像文件夾?現在,他們在bootstrap/img文件夾中。 – tipsywacky 2013-03-15 08:44:56

+0

@tipsywacky我更新了我的答案..我猜你正在使用css版本,因此請在bootstrap.css文件中找到這些行並更改它們。 – Lipis 2013-03-15 08:47:39

+0

@Lipis謝謝我看到 – 2013-03-15 08:50:36

0

你的CSS看起來OK?這是我使用的是什麼工作

- url: /img/(.*\.(gif|png|jpg)) 
    static_files: static/img/\1 
    upload: static/img/(.*\.(gif|png|jpg)) 

- url: /css 
    static_dir: static/css 

- url: /js 
    mime_type: text/javascript 
    static_dir: static/js 

那麼這應該工作等

<i class="icon-search icon-white"></i> 
+0

您不需要更改URL映射,只是爲了使圖標正常工作。閱讀我的答案更多.. – Lipis 2013-03-15 08:48:37

0

我需要添加一個步驟,使從拉立卑的工作爲我解答。

我的bootstrap.css文件中的2285行最初讀取如下,但圖標仍未顯示出來。

background-image: url("../img/glyphicons-halflings.png"); 

然後我改變這個相對路徑爲絕對路徑,如下圖所示,圖標即刻出現!

background-image: url("http://www.mywebsite.com/img/glyphicons-halflings.png"); 

至於爲什麼相對路徑沒有正確解析,那是明天的事情。同時,至少絕對路徑解決方案適用於我(也可能適用於其他人)。

非常感謝,Lipis,您的解決方案如上。

0

此主題已經過時,但也許有人正在尋找類似問題的答案。在我的情況下,在app.yaml中添加

- url: /fonts 
    static_dir: fonts 

並將bootstrap.css保留原樣。字形圖標自然應該位於根目錄中的字體文件夾中。