Bootstrap的css使用Glyphicons中的半身像图标。 如果我购买了他们的全部产品线,我该如何将其整合到bootstrap框架中?
Bootstrap的css使用Glyphicons中的半身像图标。 如果我购买了他们的全部产品线,我该如何将其整合到bootstrap框架中?
您还可以使用Font Awesome解决方案。
可缩放矢量图形意味着图标在任何大小下都非常出色。
从头开始设计,与Twitter Bootstrap 2.0完全向后兼容。
为了让字形图标生效,您需要将每个字形图标的背景定位重新计算到自己的类中,或覆盖Bootstrap已经设置的类。Twitter的Bootstrap使用免费版Halfling图标,其大小为14px,完整版则是其两倍,因此旧的background-position
将无法正常工作。
这里是一个Bootstrap图标类的示例:
/* class for the icon "fast-backward", notice the positioning values set in pixels */
.icon-fast-backward {
background-position: -216px -72px;
}
/* main class, defining what icon sheet to use */
[class^="icon-"], [class*=" icon-"] {
background-image: url("../img/glyphicons-halflings.png");
background-position: 14px 14px;
background-repeat: no-repeat;
display: inline-block;
height: 14px;
line-height: 14px;
vertical-align: text-top;
width: 14px;
}
我也在Github上创建了一个。直到之后才看到Marco的帖子。
.icon-whatever {
background:url('..img/someicon.png') 0 0;
}
默认的背景位置是14px 14px
,所以您需要像我上面所做的那样将其重置为0 0
。
icon-large
CSS类即可。<i class="icon-large icon-search"></i>
不需要将其合并。您只需添加glyphicons并与bootstrap附带的halflings一起使用即可。
按照以下方式添加glyphicons(常规设置):
/css/glyphicons.css
/fonts/glyphicons-regular.eot
/fonts/glyphicons-regular.svg
/fonts/glyphicons-regular.ttf
/fonts/glyphicons-regular.woff
/fonts/glyphicons-regular.woff2
.glyphicons
添加与 Bootstrap 的 .glyphicon
相同的样式。.glyphicons {
position:relative;
top:2px;
display:inline-block;
font-family:'Glyphicons Regular';
font-style:normal;
font-weight:normal;
line-height:1;
vertical-align:top;
-webkit-font-smoothing:antialiased;
-moz-osx-font-smoothing:grayscale
}
<link href="/css/glyphicons.css" rel="stylesheet" />
<!-- halflings / bootstrap 3 -->
<span class="glyphicon glyphicon-glass"></span>
<!-- Glyphicons Regular set (note the plural suffix!) -->
<span class="glyphicons glyphicons-glass"></span>
其他答案都很好,但要记住使用字体技术和旧技术(使用雪碧图png)的图标之间的区别。Png不总是可伸缩的,因此带有多个尺寸。此外,颜色无法设置。为了与背景形成对比,可以在png上使用.white
类将其从黑色切换到白色。通过使用字体,像样式化字体一样样式化图标:
.iconstyle { color: blue; font-size: 26px; etc.. }
这里有一篇关于Bootstrap图标的优秀文章:http://www.themplio.com/twitter-bootstrap-icons
@font-face{
font-family: 'Glyphicons Halflings';
src: url('/fonts/glyphicons-halflings-regular.eot');}
<link href="../assets/css/bootstrap.css" rel="stylesheet">
<link href="../assets/css/opa-icons.css" rel="stylesheet">
<i class="icon-close icon-red"></i> Someting <!-- 16x16pix size color red -->
<i class="icon32 icon-close icon-blue"></i> Someting <!-- 32x32pix size color red -->
您可以在此处下载相关资源(图像-图标png和css均在zip中):
http://www.photonautes-associes.fr/utils/assets.zip 祝使用愉快 :)