I would like to add badge with some number (5, 10, 100) on top of the Font Awesome symbol (fa-envelope
). For example:
But, I can not understand how to put the badge on top of the symbol. My attempt is available here: jsFiddle.
I would like to have it support Twitter Bootstrap 2.3.2.
While @Paulie_D's answer is good, it doesn't work so well when you have a variable width container.
This solution works a lot better for that: http://codepen.io/johnstuif/pen/pvLgYp
HTML:
CSS:
http://jsfiddle.net/zxVhL/16/
By placing the badge inside the icon element I was able to position it relative to the bounds of the icon container. I did all the sizing using
em
s so that the size of the badge is relative to the size of the icon and this can be changed by simply changing the font-size in.badge
This can be done with no additional mark-up, just a new class (which you would use anyway) and a pseudo element.
JSFiddle Demo
HTML
CSS
Wrap the
fa-envelope
and thespan
containing the number in adiv
and make the wrapper divposition:relative
and thespan
position:absolute
.Check this fiddle
HTML used
CSS
Hope this might help you