Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap glyphicon after position

The problem

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>

My solutions

Solution 1

<div>Next<span class="glyphicon glyphicon-chevron-right"></span></div>

Solution 2

#next.custom-chevron-right:after {
    font-family: 'Glyphicons Halflings';
    content: "\e080";
}
<div id="next" class="glyphicon custom-chevron-right">Next</div>

Source example: bootply

My question

Is there a better way to do it just with bootstrap classes?

like image 487
aleixfabra Avatar asked Mar 21 '15 16:03

aleixfabra


People also ask

How do I add a Glyphicon to my input box?

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 )

How do I use Glyphicon icons in bootstrap 5?

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.

What is bootstrap Glyphicon?

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.


Video Answer


1 Answers

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.

like image 95
Joe Conlin Avatar answered Oct 18 '22 01:10

Joe Conlin