我正在尝试在Rails应用程序中使用Bootstrap Glyphicons。我试着按照下面页面上的说明进行操作:
https://gist.github.com/iamatypeofwalrus/6467148
但当我运行我的应用程序时,图标不会出现,我在控制台中收到以下错误:
Failed to load resource: the server responded with a status of 404 (Not Found) http://0.0.0.0:3000/fonts/glyphicons-halflings-regular.woff
Failed to load resource: the server responded with a status of 404 (Not Found) http://0.0.0.0:3000/fonts/glyphicons-halflings-regular.ttf
Failed to load resource: the server responded with a status of 404 (Not Found) http://0.0.0.0:3000/assets/fonts/glyphicons-halflings-regular.woff
Failed to load resource: the server responded with a status of 404 (Not Found) http://0.0.0.0:3000/assets/fonts/glyphicons-halflings-regular.ttf
有什么想法吗?
我的字形文件都在供应商>资产>字体中
我的bootstrap-glyphicons.css文件被编辑为具有以下行:
@font-face{font-family:'Glyphicons Halflings';src:url('/assets/glyphicons-halflings-regular.eot');src:url('/assets/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),url('/assets/glyphicons-halflings-regular.woff') format('woff'),url('/assets/glyphicons-halflings-regular.ttf') format('truetype'),url('/assets/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg');}.glyphicon{position:relative;top:1px;display:inline-block;font-family:'Glyphicons Halflings';font-style:normal;font-weight:normal;line-height:1;-webkit-font-smoothing:antialiased;}
我相信您没有正确完成Gist中的步骤4。您需要更新CSS文件中的字体URL,以便它引用正确的位置。
示例:
src:url('../fonts/glyphicons-halflings-regular.eot');
成为
src:url('/assets/glyphicons-halflings-regular.eot');
根据你的错误消息,我可以看到它仍然引用了错误的位置,即/assets/fonts
(正确的路径在URL中不应该有fonts
)
问候,