Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use buttons with only glyphicons in twitter bootstrap

What is the proper markup for using a button with only a glyphicon in it in Twitter Bootstrap 3.0? If I use the following

<button type="button" class="btn btn-xs btn-danger">   <span class="glyphicon glyphicon-trash"></span> </button> 

I get something like this:

enter image description here

Update:

I did a diff between the styles on mine and @Adrift's <button> element and got the following:

# -- is mine  --webkit-perspective-origin: 12px 8px; +-webkit-perspective-origin: 12px 11px;  --webkit-transform-origin: 12px 8px; +-webkit-transform-origin: 12px 11px;  -height: 16px; +height: 22px;  -text-rendering: auto; +text-rendering: optimizelegibility; 
like image 787
Sam Selikoff Avatar asked Oct 04 '13 15:10

Sam Selikoff


People also ask

What can I use instead of Glyphicons?

Free Alternatives to Glyphicons You can use both Font Awesome and Github Octicons as a free alternative for Glyphicons.

How do I use Bootstrap Glyphicons?

Glyphicons. Bootstrap includes 260 glyphs from the Glyphicon Halflings set. Glyphicons Halflings are normally not available for free, but their creator has made them available for Bootstrap free of cost. As a thank you, you should include a link back to Glyphicons whenever possible.

Can I use Glyphicons without Bootstrap?

You will have to buy the PRO version if you want to use it without bootstrap.

How do I use Glyphicons 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.


1 Answers

Try adding a non-breaking space after the icon span.

Like this:

<button type="button" class="btn btn-xs btn-danger">   <span class="glyphicon glyphicon-trash"></span>&nbsp; </button> 
like image 195
Samuel Jack Avatar answered Sep 17 '22 13:09

Samuel Jack