12

Is it possible to "stack" the default glyphicons using Bootstrap like you can with Font Awesome's icons? Can Glyphicons do this: http://fortawesome.github.io/Font-Awesome/examples/#stacked or do I have to do custom coding?

Thanks!

redshift
  • 4,815
  • 13
  • 75
  • 138

2 Answers2

24

Here is a shorter, cleaner version (of Bass Jobsen' solution)

css

.icon-stack {
    position: relative;
}
.icon-stack .glyphicon {
    position: absolute; 
}

html

<span class="icon-stack">
   <i class="glyphicon glyphicon-unchecked"></i>
   <i class="glyphicon glyphicon-ok"></i>
</span>

example

http://jsfiddle.net/58aED/2/

markmarijnissen
  • 5,569
  • 2
  • 28
  • 34
  • I realize this is pretty old, but I have a simple question about this answer: If the glyphs are different sizes: `font-size: 2em`, they align at the corner. Is there a way to get them to align at the center? (For instance dropping a larger `glyphicon-ban-circle` over a smaller glyphicon ) – bj0 Apr 08 '16 at 18:41
  • 1
    I would use a margin or padding to accomplisch that – markmarijnissen Apr 20 '16 at 13:44
6

Bootstrap's CSS for Glyphicons don't have classes to stack. You could apply the classes from your example code: http://bootply.com/88775

css

.icon-stack {
    display: inline-block;
    height: 2em;
    line-height: 2em;
    position: relative;
    vertical-align: -35%;
    width: 2em;
}
.icon-stack .icon-stack-base {
    font-size: 2em;
}
.icon-stack [class^="icon-"], .icon-stack [class*=" icon-"] {
    display: block;
    font-size: 1em;
    height: 100%;
    line-height: inherit;
    position: absolute;
    text-align: center;
    width: 100%;
}
.icon-stack .glyphicon{
    font-size: 2em;
}
.glyphicon-ban-circle
{
    color:red;
}

html

<span class="icon-stack">
<i class="glyphicon glyphicon-phone icon-stack-base"></i>
<i class="glyphicon glyphicon-ban-circle"></i>
</span>
Bass Jobsen
  • 48,736
  • 16
  • 143
  • 224