的Rails 3 CSS3字体没有加载
问题描述:
Application.css:的Rails 3 CSS3字体没有加载
@font-face {
font-family: "Futura-Light";
src: url("/assets/Futura-Light.ttf") format("truetype"); /* For IE */
src: local("Futura-Light"), url("/assets/Futura-Light.ttf") format("truetype"); /* For non-IE */
font-weight: normal;
font-style: normal;
}
* {margin:0px;padding:0px;}
#wrap {width:730px;position:relative;font-family:"Futura-Light";}
我已经加入这个application.rb中:
config.assets.paths << "#{Rails.root}/app/assets/fonts"
和来访时,我可以下载的字体:http://localhost:3000/assets/Futura-Light.ttf
为什么字体没有加载?
答
给/ assets /留下你的网址。 Rails会为你添加这个,因为在开发和生产中这些路径可能不同。
src: url("Futura-Light.ttf") format("truetype"); /* For IE */
src: local("Futura-Light"), url("Futura-Light.ttf") format("truetype"); /* For non-IE */
答
其良好的通过使用以下所示asset_path写字体文件的路径。
src: url(<%= asset_path 'Futura-Light.ttf' %>) format('truetype'); /* For IE */ src: local("Futura-Light"), url(<%= asset_path 'Futura-Light.ttf' %>) format('truetype'); /* For non-IE */
FOund out font file corrupt ... – 2013-03-15 14:15:17