ada*_*ith 42 twitter-bootstrap glyphicons
我知道一些CSS和HTML的基础知识,有时也会使用它们,但我不是专业人士,而且我很好奇Bootstrap Glyphicons是如何工作的.我的意思是Bootstrap zip文件中没有图像,所以图像来自哪里?
mcc*_*nnf 91
在Bootstrap 2.x中,Glyphicons使用图像方法 - 使用您在问题中提到的图像.
图像方法的缺点是:
因此,在Bootstrap 2.x中使用Font-awesome而不是glyphicons,因为这使用了没有这种限制的SVG图标.
在Bootstrap 3.x中,Glyphicons使用font方法.
使用字体表示图标比使用图像更有优势:
您可以在此处查看图标的字体方法可以执行的操作.
所以在Bootstrap发行版中,你可以看到glyphicon字体文件:
fonts\glyphicons-halflings-regular.eot
fonts\glyphicons-halflings-regular.svg
fonts\glyphicons-halflings-regular.ttf
fonts\glyphicons-halflings-regular.woff
Run Code Online (Sandbox Code Playgroud)
Bootstrap CSS引用了glyphicon字体,如下所示:
@font-face {
font-family: 'Glyphicons Halflings';
src: url('../fonts/glyphicons-halflings-regular.eot');
src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
Run Code Online (Sandbox Code Playgroud)
CSS使用.glyphicon
基类链接到这个字体(注意font-family
):
.glyphicon {
position: relative;
top: 1px;
display: inline-block;
font-family: 'Glyphicons Halflings';
font-style: normal;
font-weight: normal;
...
}
Run Code Online (Sandbox Code Playgroud)
然后每个glyphicon使用一个单独的图标类,它引用 Glyphicon Halflings字体中的Unicode引用,例如:
.glyphicon-envelope:before {
content: "\2709";
}
Run Code Online (Sandbox Code Playgroud)
这就是为什么你必须.glyphicon
对span
Bootstrap 3 中的元素使用基类和单独的图标类:
<span class="glyphicon glyphicon-envelope"></span>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
19772 次 |
最近记录: |