2015-04-02 63 views
0

我有導軌4.2.1使用引導程序3.3.x和圖形的應用程序。我不能使用boostrap-sass或任何其他gems來將bootstrap與rails集成,因爲原始bootstrap.css已被設計者修改。我也有一個custom.css文件。自舉圖形3.3.4無法在導軌中工作4.2.1

我已經改名爲所有CSS文件(應用程序,引導和定製)使用SCSS格式。目前,引導CSS正常工作,但不顯示圖形。我已經取代了bootstrap.scss字型臉代碼

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

以前(fontawesome + rails 4.0.1 not working),我沒有在軌使用不同的字體配置SCSS文件和它的工作。我在當前的rails應用程序中嘗試了相同的方法,但無法弄清楚它爲什麼失敗。這裏(https://github.com/prasadsurase/rails-fonts.git)是一個示例rails應用程序來檢查問題。

感謝您的任何建議。

回答

1

您在SCSS中有錯誤。該@font-face應該聲明如下:

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

注意,恰好有2種src規格。第一個src有一個url(),第二個src有多個用逗號分隔的url()聲明,而不是分號。

+0

如果我們更換;如你指定的,在「src」之後得到「無效的CSS:expected」;「,was」:url(font-path ...「」error。 – 2015-04-03 05:00:22

+0

我克隆了你的repo並做了這個修改, 。很確定它的工作原理:)你是從我的答案中完全複製'@ font-face'代碼嗎? – 2015-04-03 05:01:46

+0

感謝您的回答。被困了幾個小時。 – 2015-04-03 06:30:52