Is there an easy way of increasing the size of Glyphicons?
I found some solution like Font Awesome but don't want to include new CSS library just to increase size 2 icons.
11 Answers
This is one way to increase the size of icons in Bootstrap 2.3. As I note in my comment, the results will be pretty poor because you are scaling the spritesheet image.
.test {
background-image: url("http://twitter.github.io/bootstrap/assets/img/glyphicons-halflings.png");
width: 90px;
height: 90px;
background-size: 2100px 800px;
}
Consider Fontello instead. They allow you to generate a custom font based on the icons you choose.
As of Bootstrap 3, glyphicons have been changed into fonts rather than sprites. This gives you more flexibility. For example, you can just set the font-size
and move on.
<span class="glyphicon glyphicon-adjust" style="font-size:48px;"></span>
Or you can simply write a modifier class:
.glyphicon-2x {
font-size: 48px;
}
Just need to set the fontsize up :) You have more than one option to do this:
First (set it straight to the element)
<span class="glyphicon glyphicon-search" style="font-size:30px"></span>
Second (set it in a css file)
.glyphicon{
font-size: 30px;
}
Third (build modify-classes) [i prefer this posibility]
.glyphicon-2x{
font-size: 40px;
}
.glyphicon-3x{
font-size: 60px;
}
...
Usage:
<span class="glyphicon glyphicon-2x glyphicon-search"></span>
there are more options to get the third one more tiny. there for you should read more about Less
according to your question and the comment that brandon gave me, you can use the above with a other icon contianer.
Bootstrap 2.3
First
<i class="icon-search" style="-webkit-transform:scale(1.8);"></i>
Second
.icon-search{
-webkit-transform:scale(1.8);
-moz-transform:scale(1.8);
-o-transform:scale(1.8);
}
Third
.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>
If you use the glyphicons for buttons it's pretty simple:
<button type="button" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-star"></span>
</button>
The btn-lg defines the size. You can use btn-lg, bnt-sm, btn-sx
Edit: If you don't use buttons or lg is not large enough, you can add an own class and use font-size (only tested in bootstrap 3.0). In bootstrap 3.0 glyphicons exist as .svg so they won't look ugly
Example:
<button type="button" class="btn btn-default btn-lg myGlyphicon">
<span class="glyphicon glyphicon-star"></span>
</button>
CSS:
.myGlyphicon {font-size: 120%;}
or
.myGlyphicon {font-size: 70px;}
You can use IcoMoon.io a very easy to use tool for generating icon font of different colours ,size's and even you can generate sprites from you selection.
If you're using Bootstrap 3, why don't you use em
widths on the icon? If the icons are embedded within headings/paragraphs/bodies etc. then using a font size in em
s will increase the size of the icons relative to the paragraph that they're in.
For example, if you have:
<span class="glyphicon glyphicon-adjust"></span>
In the css that customizes your bootstrap, simply add:
.glyphicon {font-size: 1.25 em;}
This will scale the glyphs.