Bootstrap 字体图标(Glyphicons)

摘要:
在fonts文件夹内可以找到字体图标,它包含了下列这些文件:glyphicons-halflings-regular.eotglyphicons-halflings-regular.svgglyphicons-halflings-regular.ttfglyphicons-halflings-regular.woff相关的CSS规则写在dist文件夹内的css文件夹内的bootstrap.css和bootstrap-min.css文件上。所以font-face规则实际上是在找到glyphicons地方声明font-family和位置。.glyphiconclass声明一个从顶部偏移1px的相对位置,呈现为inline-block,声明字体,规定font-style和font-weight为normal,设置行高为1。然后,这里的.glyphicon:empty{width:1em;}是空的glyphicon。这些class的常见格式如下:.glyphicon-keyword:before{content:"hexvalue";}比如,使用的user图标,它的class如下:.glyphicon-user:before{content:"\e008";}用法如需使用图标,只需要简单地使用下面的代码即可。

http://www.runoob.com/bootstrap/bootstrap-glyphicons.html

什么是字体图标?

字体图标是在 Web 项目中使用的图标字体。虽然,Glyphicons Halflings 需要商业许可,但是您可以通过基于项目的 Bootstrap 来免费使用这些图标。

为了表示对图标作者的感谢,希望您在使用时加上 GLYPHICONS 网站的链接。


获取字体图标

我们已经在 环境安装 章节下载了 Bootstrap 3.x 版本,并理解了它的目录结构。在 fonts 文件夹内可以找到字体图标,它包含了下列这些文件:

  • glyphicons-halflings-regular.eot
  • glyphicons-halflings-regular.svg
  • glyphicons-halflings-regular.ttf
  • glyphicons-halflings-regular.woff

相关的 CSS 规则写在 dist 文件夹内的 css 文件夹内的 bootstrap.cssbootstrap-min.css 文件上。

所以 font-face 规则实际上是在找到 glyphicons 地方声明 font-family 和位置。

.glyphicon class 声明一个从顶部偏移 1px 的相对位置,呈现为 inline-block,声明字体,规定 font-style 和 font-weight 为 normal,设置行高为 1。除此之外,使用 -webkit-font-smoothing: antialiased-moz-osx-font-smoothing: grayscale; 获得跨浏览器的一致性。

然后,这里的

.glyphicon:empty {width:1em;}

是空的 glyphicon。

这里有 200 个 class,每个 class 针对一个图标。这些 class 的常见格式如下:

.glyphicon-keyword:before {content:"hexvalue";}

比如,使用的 user 图标,它的 class 如下:

.glyphicon-user:before {content:"\e008";}

用法

如需使用图标,只需要简单地使用下面的代码即可。请在图标和文本之间保留适当的空间。

<spanclass="glyphicon glyphicon-search"></span>

免责声明:文章转载自《Bootstrap 字体图标(Glyphicons)》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇ETF计算公司:现金差额【CentOS6.5】安装nginx报错:No package nginx available. Error: Nothing to do下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Bootstrap-CL:字体图标(Glyphicons)

ylbtech-Bootstrap-CL:字体图标(Glyphicons) 1.返回顶部 1、 Bootstrap 字体图标(Glyphicons)本章将讲解字体图标(Glyphicons),并通过一些实例了解它的使用。Bootstrap 捆绑了 200 多种字体格式的字形。首先让我们先来理解一下什么是字体图标。 什么是字体图标? 字体图标是在 Web...