有没有一种简单的方法可以增加Glyphicons的大小?
我找到了一些解决方案,例如Font Awesome,但不想包含新的CSS库只为了将2个图标的大小增加。
有没有一种简单的方法可以增加Glyphicons的大小?
我找到了一些解决方案,例如Font Awesome,但不想包含新的CSS库只为了将2个图标的大小增加。
将 <span> 标签的字号设置为适当大小对我很有帮助
<span class="glyphicon glyphicon-ok" style="font-size: 20px;"></span>
span(style="font-size:24px").glyphicon.glyphicon-info-sign
。该代码用于在网页中显示一个大小为24px的信息图标。 - Tarion自Bootstrap 3起,字形图标已更改为字体而不是精灵。 这样可以使您更加灵活。例如,您只需设置font-size
并继续进行。
<span class="glyphicon glyphicon-adjust" style="font-size:48px;"></span>
或者您可以直接编写一个修改器类:
.glyphicon-2x {
font-size: 48px;
}
只需要将字体大小设置大一些就好了 :)
第一种方法 (将字体大小直接设置到元素上)
<span class="glyphicon glyphicon-search" style="font-size:30px"></span>
第二步(在CSS文件中设置)
.glyphicon{
font-size: 30px;
}
第三步(构建修改类)[我更喜欢这种可能性]
.glyphicon-2x{
font-size: 40px;
}
.glyphicon-3x{
font-size: 60px;
}
...
使用方法:
<span class="glyphicon glyphicon-2x glyphicon-search"></span>
有更多选项可以使第三个更加精简。因此,您应该阅读更多关于Less的内容。
根据您的问题和Brandon给我的评论,您可以将上述内容与其他图标容器一起使用。
首先
<i class="icon-search" style="-webkit-transform:scale(1.8);"></i>
第二
.icon-search{
-webkit-transform:scale(1.8);
-moz-transform:scale(1.8);
-o-transform:scale(1.8);
}
第三
.icon-x2{
-webkit-transform:scale(2.0);
-moz-transform:scale(2.0);
-o-transform:scale(2.0);
}
.icon-x3{
-webkit-transform:scale(3.0);
-moz-transform:scale(3.0);
-o-transform:scale(3.0);
}
//here i use the css from above (Bootstrap 3)
//actually you can name it like you want
<i class="icon-search icon-2x"></i>
font-size
似乎无法改变图标大小http://jsfiddle.net/Lk5vd/ - Brian Jordan这是在Bootstrap 2.3中增加图标大小的一种方法。正如我在评论中指出的那样,结果会相当糟糕,因为你正在缩放精灵图像。
.test {
background-image: url("http://twitter.github.io/bootstrap/assets/img/glyphicons-halflings.png");
width: 90px;
height: 90px;
background-size: 2100px 800px;
}
考虑使用Fontello代替,它们允许你基于所选图标生成自定义字体。
您可以使用:
.icon-whatever {
zoom: 2;
-moz-transform: scale(2); /* Firefox */
}
然而,当您放大图像时,它会变得模糊不清,因为它正在缩放图像。使用字体图标库将具有更好的缩放效果。
// Size and position are not working.
.icon-glass {
background-size: 800px;
backgroung-position: 10px 50px;
width: 24px;
height: 24px;
}
问题在于图标由于分辨率会显得模糊不清。
希望这有所帮助!
<button type="button" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-star"></span>
</button>
btn-lg定义了按钮的大小。您可以使用btn-lg、btn-sm、btn-sx。
编辑: 如果您不使用按钮或lg不够大,可以添加自己的类并使用font-size(仅在bootstrap 3.0中测试过)。在bootstrap 3.0中,图标存在为.svg,因此它们看起来不会很丑陋。
示例:
<button type="button" class="btn btn-default btn-lg myGlyphicon">
<span class="glyphicon glyphicon-star"></span>
</button>
CSS:
.myGlyphicon {font-size: 120%;}
或者
.myGlyphicon {font-size: 70px;}
em
宽度? 如果图标嵌入标题/段落/正文等中,则使用em
字体大小将相对于它们所在的段落增加图标的大小。<span class="glyphicon glyphicon-adjust"></span>
.glyphicon {font-size: 1.25 em;}
这将缩放字形。
.glyphicon-chevron-right {transform:scale(2.9,2.9);}