我必須在一個Rails應用程序中使用Google的字體。普通的HTML代碼定義googlefonts用法是這樣的:在Ruby on Rails 3.2應用程序中集成googlefonts
<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
我嘗試添加同一行中我alpplication.html.erb,但沒有奏效。然後我萃取@字體面定義(由鏈路的href指向的位置)到一個單獨的文件css.scss幷包括在我的清單的CSS文件的文件:
#googlefonts.css.scss
@font-face {
font-family: 'PT Sans';
font-style: italic;
font-weight: 400;
src: local('PT Sans Italic'), local('PTSans-Italic'), url(http://themes.googleusercontent.com/static/fonts/ptsans/v4/xxxx.woff) format('woff');
}
#application.css
*= require googlefonts
*= require_tree .
它沒有再發生。
請幫我解決難題。 Rails 3應用程序中使用谷歌的最佳做法是什麼?
編輯:這裏是我的CSS,指的是@字體面的定義:
#styles.css.scss
body{
font-family: "PT Sans", Arial, Helvetica, sans-serif;
font-size:13px;
line-height:25px;
text-shadow:none !important;
color:#444;
}
請在您使用'PT Sans'的地方添加CSS選擇器 –
感謝您的關注,我編輯了我的問題。 –