为什么nginx环境下bootstrap中font-font awesome动态图标图标显示不出来

收藏,5.3k 浏览
问题对人有帮助,内容完整,我也想知道答案
问题没有实际价值,缺少关键内容,没有改进余地
潜水很久,第一次在segmentfault提问题,
最近开始研究bootstrap,也发现了font-awesome这个好东西,
昨天在从网上down了一份基于bootstrap的前端模板,
发现font-awesome图标均无法正常显示,排除了浏览器的问题,
因为逐个的在safari、chrome、firefox、IE11下面都测试过了
IE11 =》完全不显示
safari、Chorome =》 应该显示图标的地方显示了一个个的小方框
在搜索引擎搜索过一些答案,发现别人同样问题只出现在firefox上面,
原因是:nginx的跨域访问问题
解决方法是在nginx中增加一个响应头:
location ~* \.(eot|otf|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
我也按照这种方案做了,可还是无法显示
浏览器调试模式下,有个错误信息如下:
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (fontawesome-webfont.woff, line 0)
用浏览器去访问这个文件也是访问不到的,提示error404!
http://localhost/admin-pages/fickle/assets/css/font-awesome/fonts/fontawesome-webfont.svg?v=4.1.0
症状图片如下:感谢。12月17日补充:
问题解决了,不是nginx的问题,我犯了一个低级错误,这套html模板是我用wget下载的,在下载时候wget根据链接请求自动在字体文件扩展名后面加了参数,本来一个ttf字体变成了xxx.ttf?v=4.0.1 难怪请求字体文件提示404.修正一下文件扩展名都可以显示出来了。
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
请求404的是svg文件吗?nginx的配置里没有svg,加上svg试一下?
location ~* \.(eot|otf|ttf|woff|svg)$ {
add_header Access-Control-Allow-Origin *;
分享到微博?
与我们一起探索更多的未知
专业的开发者技术社区,为用户提供多样化的线上知识交流,丰富的线下活动及给力的工作机会
加入只需一步
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)
举报理由:
推广(招聘、广告、SEO 等)方面的内容
带有人身攻击、辱骂、仇恨等违反条款的内容
与已有问题重复(请编辑该提问指向已有相同问题)
不友善内容
答非所问,不符合答题要求
其他原因(请补充说明)
补充说明:
扫扫下载 App
SegmentFault
一起探索更多未知向ratchet中添加font&awesome&图标
ratchet中的图标在bootstrap的基础上进行缩减
font awesome 的图标在bootstrape的基础上进行增加.
查询向 ratchet添加自定义文字图,资料了了.
现给出方法:
其它官方说的很清楚了,只是说明在了bootstrap中,经实测,在ratchet中也是适用的.
参考:/p/font-awesome/
font-awesome文档
注意的是查询CSS文件中的font文件夹,应该变成fonts
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。Font Awesome, 为 Bootstrap 而创造的图标字体
Font Awesome
完美的图标字体只为Bootstrap设计
Version 3.0.2 o Created & Maintained by Dave Gandy
一个字体文件, 249 个图标
一个字体文件包含了所有图标。Font Awesome 助你完整表达web页面上每个动作的含义。
用CSS控制样式
用CSS能非常容易的改变这些图标的颜色、大小、阴影以及任何CSS能控制的属性。
矢量图意味着每个图标都能在所有大小的屏幕上完美呈现。
个人、商业均可自由使用
Font Awesome是完全免费的,无论个人还是商业使用。详见 。
Font Awesome支持IE7及以上浏览器。不过你要是必须用在这种过时的浏览器上话,我只能表示同情!
在Retina屏幕上也能完美呈现
Font Awesome 中包含的都是矢量图标,在高分辨率的显示器上也能完美呈现。
专为Bootstrap设计
Font Awesome是完全从头设计的整套图标,完全和版本兼容.
设计师的助手
安装 FontAwesome.otf 字体文件,然后在直接拷贝粘贴图标字符的代码就可以用于你的设计中了。
兼容屏幕阅读器
Font Awesome 不会阻止屏幕阅读器,这和其他图标字体的行为方式完全不同。
完美的 14px 字号
每个图标都是重新制作的,并且针对Bootstrap的默认14px字号做了最大的优化。
and , you can
to get just the icons you need.
我们遵循 SIL 开放字体协议,代码遵循 MIT 协议。没有过多的束缚,带给你更多自由。
3.0版本新增 40 个全新的图标
我们拥有活跃的社区,聆听大众的需求。 .
for animated spinning icons, icons with 2x-4x size multipliers, icon borders, & more.
虽然增加了 16% 的图标,3.0 版本的体积却变得更小了。 Font Awesome 还可以定制,将你不需要的图标去掉。
Font Awesome 3.0版本中新增了40个全新的图标。如果你需要更多新图标,可以在
提出需求,或者,你也可以 。
icon-cloud-download
icon-cloud-upload
icon-lightbulb
icon-exchange
icon-bell-alt
icon-file-alt
icon-coffee
icon-fighter-jet
icon-user-md
icon-stethoscope
icon-suitcase
icon-building
icon-hospital
icon-ambulance
icon-medkit
icon-h-sign
icon-plus-sign-alt
icon-spinner
icon-angle-left
icon-angle-right
icon-angle-up
icon-angle-down
icon-double-angle-left
icon-double-angle-right
icon-double-angle-up
icon-double-angle-down
icon-circle-blank
icon-circle
icon-desktop
icon-laptop
icon-tablet
icon-mobile-phone
icon-quote-left
icon-quote-right
icon-reply
icon-github-alt
icon-folder-close-alt
icon-folder-open-alt
icon-adjust
icon-asterisk
icon-ban-circle
icon-bar-chart
icon-barcode
icon-beaker
icon-bell-alt
icon-bookmark
icon-bookmark-empty
icon-briefcase
icon-bullhorn
icon-calendar
icon-camera
icon-camera-retro
icon-certificate
icon-check
icon-check-empty
icon-circle
icon-circle-blank
icon-cloud
icon-cloud-download
icon-cloud-upload
icon-coffee
icon-comment
icon-comment-alt
icon-comments
icon-comments-alt
icon-credit-card
icon-dashboard
icon-desktop
icon-download
icon-download-alt
icon-envelope
icon-envelope-alt
icon-exchange
icon-exclamation-sign
icon-external-link
icon-eye-close
icon-eye-open
icon-facetime-video
icon-fighter-jet
icon-filter
icon-folder-close
icon-folder-open
icon-folder-close-alt
icon-folder-open-alt
icon-glass
icon-globe
icon-group
icon-headphones
icon-heart
icon-heart-empty
icon-inbox
icon-info-sign
icon-laptop
icon-legal
icon-lemon
icon-lightbulb
icon-unlock
icon-magic
icon-magnet
icon-map-marker
icon-minus
icon-minus-sign
icon-mobile-phone
icon-money
icon-music
icon-ok-circle
icon-ok-sign
icon-pencil
icon-picture
icon-plane
icon-plus-sign
icon-print
icon-pushpin
icon-qrcode
icon-question-sign
icon-quote-left
icon-quote-right
icon-random
icon-refresh
icon-remove
icon-remove-circle
icon-remove-sign
icon-reorder
icon-reply
icon-resize-horizontal
icon-resize-vertical
icon-retweet
icon-screenshot
icon-search
icon-share
icon-share-alt
icon-shopping-cart
icon-signal
icon-signin
icon-signout
icon-sitemap
icon-sort-down
icon-sort-up
icon-spinner
icon-star-empty
icon-star-half
icon-tablet
icon-tasks
icon-thumbs-down
icon-thumbs-up
icon-trash
icon-trophy
icon-truck
icon-umbrella
icon-upload
icon-upload-alt
icon-user-md
icon-volume-off
icon-volume-down
icon-volume-up
icon-warning-sign
icon-wrench
icon-zoom-in
icon-zoom-out
icon-file-alt
icon-paste
icon-repeat
icon-text-height
icon-text-width
icon-align-left
icon-align-center
icon-align-right
icon-align-justify
icon-indent-left
icon-indent-right
icon-italic
icon-strikethrough
icon-underline
icon-paper-clip
icon-columns
icon-table
icon-th-large
icon-th-list
icon-list-ol
icon-list-ul
icon-list-alt
icon-angle-left
icon-angle-right
icon-angle-up
icon-angle-down
icon-arrow-down
icon-arrow-left
icon-arrow-right
icon-arrow-up
icon-caret-down
icon-caret-left
icon-caret-right
icon-caret-up
icon-chevron-down
icon-chevron-left
icon-chevron-right
icon-chevron-up
icon-circle-arrow-down
icon-circle-arrow-left
icon-circle-arrow-right
icon-circle-arrow-up
icon-double-angle-left
icon-double-angle-right
icon-double-angle-up
icon-double-angle-down
icon-hand-down
icon-hand-left
icon-hand-right
icon-hand-up
icon-circle
icon-circle-blank
icon-play-circle
icon-pause
icon-step-backward
icon-fast-backward
icon-backward
icon-forward
icon-fast-forward
icon-step-forward
icon-eject
icon-fullscreen
icon-resize-full
icon-resize-small
icon-phone
icon-phone-sign
icon-facebook
icon-facebook-sign
icon-twitter
icon-twitter-sign
icon-github
icon-github-alt
icon-github-sign
icon-linkedin
icon-linkedin-sign
icon-pinterest
icon-pinterest-sign
icon-google-plus
icon-google-plus-sign
icon-sign-blank
icon-ambulance
icon-beaker
icon-h-sign
icon-hospital
icon-medkit
icon-plus-sign-alt
icon-stethoscope
icon-user-md
将Font Awesome 集成到 Bootstrap 非常容易,还可以被单独使用。
最简单的 Bootstrap + Font Awesome 集成方式
使用这种方式将 Font Awesome 集成到默认的 Bootstrap CSS中。
拷贝 Font Awesome 字体目录到你的项目中。
font-awesome.min.css 文件到你的项目中。
打开你的项目中的 font-awesome.min.css 文件并编辑字体路径指向正确的位置。
在html文档中的 &head& 部分,引入 font-awesome.min.css 文件。
&link rel="stylesheet" href="../css/bootstrap.min.css"&
&link rel="stylesheet" href="../css/font-awesome.min.css"&
在浏览器中打开页面,检查是否正确启用了 Font Awesome!
自定义 Bootstrap + Font Awesome LESS文件的方式进行集成
修改Bootstrap的LESS文件以集成 Font Awesome。
拷贝 Font Awesome 字体目录到你的项目中。
拷贝 font-awesome.less 文件到 bootstrap/less 目录。
打开 bootstrap.less 文件,并将 @import "sprites.less"; 替换为 @import "font-awesome.less";
打开你的项目中的 font-awesome.less 文件,并编辑 @FontAwesomePath 变量,将其值替换为指向字体文件的正确路径。
@FontAwesomePath:
"../font";
重新编译Bootstrap的所有 LESS 文件。如果你使用的是less.js脚本动态编译的话就能直接在浏览器中看到效果了。
在浏览器中打开页面,检查是否正确启用了 Font Awesome!
自定义 Bootstrap + Font Awesome 集成,并使用 SASS 或 SCSS
我也从未使用过SASS或SCSS,如果源码包中的SCSS或SASS文件有问题的话请通知我。
不使用 Bootstrap?
Font Awesome works just as well without Twitter Bootstrap.
Copy the Font Awesome font directory into your project.
Copy font-awesome.less or font-awesome.min.css into your project.
Open your project's font-awesome.less or font-awesome.min.css and edit the font location to point it to your font directory (see above examples).
Check out the examples to start using Font Awesome!
需要支持 IE7 浏览器?
Font Awesome supports IE7. If you need it, you have my condolences.
Get Font Awesome working properly in a modern browser.
Copy font-awesome-ie7.min.css into your project.
In the &head& of your html, reference the location to your font-awesome-ie7.min.css.
&link rel="stylesheet" href="../css/bootstrap.min.css"&
&link rel="stylesheet" href="../css/font-awesome.min.css"&
&!--[if IE 7]&
&link rel=&stylesheet& href=&assets/css/font-awesome-ie7.min.css&&
&![endif]--&
Go complain to whoever decided your project needs IE7 support.
下面的案例大部分都是重用 Bootstrap 文档中的案例。
Use Font Awesome icons in:
Bulleted lists (like this one)
Button groups
Navigation
Prepended form inputs
And many more with Custom CSS
Use a few of the new styles together, and you've got easy pull quotes or a great introductory article image.
Or spinning icons for loading and refreshing content. Or fun big icons in multi-line buttons. Lots of new possibilities.
Spinner icon when loading content...
Inline Icons
Place Font Awesome icons just about anywhere with the &i& tag.
icon-camera-retro
&i class="icon-camera-retro"&&/i& icon-camera-retro
更大的图标
通过给图标设置 icon-large、icon-2x、
icon-3x 或 icon-4x 样式,可以让图标相对于它所在的容器变得更大。
通过应用 icon-large (增大 33%), icon-2x,
icon-3x 或 icon-4x 样式让图标变得更大。
icon-camera-retro
icon-camera-retro
icon-camera-retro
icon-camera-retro
&p&&i class=&icon-camera-retro icon-large&&&/i& icon-camera-retro&/p&
&p&&i class=&icon-camera-retro icon-2x&&&/i& icon-camera-retro&/p&
&p&&i class=&icon-camera-retro icon-3x&&&/i& icon-camera-retro&/p&
&p&&i class=&icon-camera-retro icon-4x&&&/i& icon-camera-retro&/p&
Animated Spinner
Use the icon-spin class to get any icon to rotate. Works best with icon-spinner and
icon-refresh.
Spinner icon when loading content...
&i class=&icon-spinner icon-spin&&&/i& Spinner icon when loading content...
Bordered & Pulled Icons
Use icon-border and pull-right or pull-left for easy pull quotes or
article graphics.
Use a few of the new styles together, and you've got easy pull quotes or a great introductory article image.
Or spinning icons for loading and refreshing content. Or fun big icons in multi-line buttons. You can combine all
of them in any combination to get lots of new possibilities.
&i class=&icon-quote-left icon-4x pull-left icon-muted&&&/i&
Use a few of the new styles together ... lots of new possibilities.
Use a few of the new styles together, and you've got easy pull quotes or a great introductory article image.
Or spinning icons for loading and refreshing content. Or fun big icons in multi-line buttons. You can combine all
of them in any combination to get lots of new possibilities.
&i class=&icon-flag icon-4x pull-left icon-border&&&/i&
Use a few of the new styles together ... lots of new possibilities.
Font Awesome 图标能够很好的应用于按钮组件中。将图标设置的再大也可以,Bootstrap中的
pull-right、 pull-left 和 icon-spin 样式都可以应用到图标上。
&a class="btn" href="#"&
&i class="icon-repeat"&&/i& Reload&/a&
&a class="btn btn-success" href="#"&
&i class="icon-shopping-cart icon-large"&&/i& Checkout&/a&
&a class="btn btn-large btn-primary" href="#"&
&i class="icon-comment"&&/i& Comment&/a&
&a class="btn btn-small btn-info" href="#"&
&i class="icon-info-sign"&&/i& Info&/a&
&a class="btn btn-danger" href="#"&
&i class="icon-trash icon-large"&&/i& Delete&/a&
&a class="btn btn-small" href="#"&
&i class="icon-cog"&&/i& Settings&/a&
&a class=&btn btn-large btn-danger& href=&#&&
&i class=&icon-flag icon-2x pull-left&&&/i&Font Awesome&br&Version 3.0&/a&
&a class=&btn btn-primary& href=&#&&
&i class=&icon-refresh icon-spin&&&/i& Synchronizing Content...&/a&
&div class="btn-group"&
&a class="btn" href="#"&&i class="icon-align-left"&&/i&&/a&
&a class="btn" href="#"&&i class="icon-align-center"&&/i&&/a&
&a class="btn" href="#"&&i class="icon-align-right"&&/i&&/a&
&a class="btn" href="#"&&i class="icon-align-justify"&&/i&&/a&
下拉菜单按钮
&div class="btn-group open"&
&a class="btn btn-primary" href="#"&&i class="icon-user"&&/i& User&/a&
&a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#"&&span class="icon-caret-down"&&/span&&/a&
&ul class="dropdown-menu"&
&li&&a href="#"&&i class="icon-pencil"&&/i& Edit&/a&&/li&
&li&&a href="#"&&i class="icon-trash"&&/i& Delete&/a&&/li&
&li&&a href="#"&&i class="icon-ban-circle"&&/i& Ban&/a&&/li&
&li class="divider"&&/li&
&li&&a href="#"&&i class="i"&&/i& Make admin&/a&&/li&
Button groups
Navigation
Prepended form inputs
Easily replace individual bullets.
&ul class="icons"&
&li&&i class="icon-ok"&&/i& Lists&/li&
&li&&i class="icon-ok"&&/i& Buttons&/li&
&li&&i class="icon-ok"&&/i& Button groups&/li&
&li&&i class="icon-ok"&&/i& Navigation&/li&
&li&&i class="icon-ok"&&/i& Prepended form inputs&/li&
Use Font Awesome icons in navigation to provide helpful visual cues.
&ul class="nav nav-list"&
&li class="active"&&a href="#"&&i class="icon-home"&&/i& Home&/a&&/li&
&li&&a href="#"&&i class="icon-book"&&/i& Library&/a&&/li&
&li&&a href="#"&&i class="icon-pencil"&&/i& Applications&/a&&/li&
&li&&a href="#"&&i class="icon-cogs"&&/i& Settings&/a&&/li&
Prepended form inputs
&div class="input-prepend"&
&span class="add-on"&&i class="icon-envelope"&&/i&&/span&
&input class="span2" type="text" placeholder="Email address"&
&div class="input-prepend"&
&span class="add-on"&&i class="icon-key"&&/i&&/span&
&input class="span2" type="password" placeholder="Password"&
自定义 CSS
普通字体可以被赋予的CSS样式也能同样应用到 Font Awesome 上。
评定星级 (inspired by )
Want to help make Font Awesome even more awesome? Contribute back to the Font Awesome community by designing
new pictograms for the set.
If selected, you'll retain the CC-BY license to your pictogram and get attribution
right here on the Font Awesome site.
How to Submit New Icons
Download the .
Open the PDF in Adobe Illustrator. You'll notice the file has dimensions of 60x56. This is exactly 4x the
max icon size of 15 wide by 14 tall. The template is an example of the flag icon to use as a guide.
Design your icon. In order to make it into the set, your icon must look pixel perfect. The easiest way to do
this is to make sure your line widths in the template are some multiple of 4px. Diagonals are rough, too.
Don't split pixels right down the middle, as they blur more when rendering. Zoom out to 25% to get a good idea
of how it will render in the font.
Submit your icon. Drop me an email at . Make sure to
use the subject [Font Awesome] [Icon Contribution] icon-name and attach your PDF file. If your
icon makes it into Font Awesome (I'm keeping a very tight reign on quality), I'll ask what contact info you'd
like to use for attribution.
下面是将来版本更新的计划。
Easier sub-setting with icon packs.
More icons. Have any requests?
in the Font Awesome GitHub project.
Tricks and tips for super-awesome creative CSS methods, like the star example above.
The Font Awesome font is licensed under the .
Font Awesome CSS, LESS, and SASS files are licensed under the .
The Font Awesome pictograms are licensed under the
Attribution is no longer required in Font Awesome 3.0, but much appreciated: Font Awesome by Dave Gandy - /Font-Awesome.
I'm the lead product designer at Kyruus. I wake up every single day excited about my job.
Why? Kyruus is going to change healthcare. No exaggeration.
Kyruus is a well-funded, big data healthcare startup in Boston. We believe that the right data at the right time
can help doctors make better decisions. We believe data can save lives.
What I love about Kyruus:
Product design. From the top of the organization, Kyruus is committed to product design done right. It's awesome.
Purpose. Every day, I get to help make the world a better place – a little at a time.
People. I work with some of the best people I've ever met. More than just smart people. Good people.
Kyruus needs good people. Designers, app developers, big data masters, & interns that get real responsibility. Come work with me.
Interested?
Hopefully you think Font Awesome is awesome. I've put hundreds of hours into the project to give back to the
open source community. If you'd like, here are some ways you can tell me thanks for all my hard work.
to make Font Awesome even awesome-er.
to a shiny
new iMac for me to keep making great icons.
Or pick something straight
from . Gift cards are great.
Work: Lead Product Designer @
Special Thanks
Special thanks to
for icon design
review, advice, and some backbone.js help.
Special thanks to
for developing
, the best way to subset Font Awesome to get just the
icons you need.
Font Awesome 中文文档由翻译整理。

我要回帖

更多关于 font awesome图标 的文章

 

随机推荐