I want to display a glyphicon icon after a text. In the documentation, there are only before examples as you can see here: http://getbootstrap.com/components/#glyphicons-examples
<div class="glyphicon glyphicon-chevron-right">Next</div>
<div>Next<span class="glyphicon glyphicon-chevron-right"></span></div>
#next.custom-chevron-right:after {
font-family: 'Glyphicons Halflings';
content: "\e080";
}
<div id="next" class="glyphicon custom-chevron-right">Next</div>
Source example: bootply
Is there a better way to do it just with bootstrap classes?
glyphicon to the HTML element you want to contain an icon. Add a class that specifies the icon you which to use (e.g . glyphicon-minus )
In lines 15 and 17 the <span> and <a> element has the bootstrap glyphicon glyphicon-pencil classes, so to use any glyphicon in bootstrap: Use the <span> or <a> element. Set the class attribute of the <span> or <a> element as glyphicon then a space and then glyphicon-iconname.
Generally, Glyphicons are icon fonts which you can use in your web projects. Bootstrap includes 260 glyphicons. These glyphicons used for web project from Bootstrap Glyphicons Halflings Set. Glyphicons Halflings are not available for free of cost, but their creator has made them available for Bootstrap free of cost.
There are 2 ways to typically add glyphicons (or any other icon font being used). The first way it to add them via html.
<div>Next <span class="glyphicon glyphicon-chevron-right"></span></div>
// Be sure to add a space in between your text and the icon
The second way it to do it using CSS. At a minimum, you must include the font-family and character code.
<div><span>Next</span></div>
span::after {
font-family: 'Glyphicons Halflings';
content: "\e080";
}
Obviously, using the CSS method you can then add additional styling but this example shows you the minimum needed to get thte icon to appear in the relative correct place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With