Reputation: 12704
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:
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;
Upvotes: 33
Views: 85412
Reputation: 2451
As of Bootstrap 5, using Bootstrap Icons this is the way to go:
<button type="button" class="btn btn-success">
<i class="bi bi-telephone-plus"></i>
</button>
Upvotes: 0
Reputation: 241
Hi I had the same problem.
I found out that <!DOCTYPE html>
was missing in index.html.
After I added this the button had right away the right size.
Hope this helps ;)
Upvotes: 2
Reputation: 151
Simply use
<span role="button" class="glyphicon glyphicon-trash btn-lg" onclick="yourFunction()"></span>
Upvotes: 0
Reputation: 291
Or you could just use the glyphicon itself as a button
<div id="TrashButton" class="glyphicon glyphicon-trash" style="cursor:pointer"></div>
and then set an "onclick" method for it...
$("#TrashButton").on("click", function () {
//do something
});
Upvotes: 1
Reputation: 33280
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>
</button>
Upvotes: 42
Reputation: 4774
Seems like a little late but the correct answer is:
<button class="btn btn-info" type="button"> <span class="glyphicon glyphicon-refresh"></span> </button>
You have to add both glyphicon and glyphicon-{type} in the span class, a not a element. Good Luck
Upvotes: 3
Reputation: 746
(prior to version 3.0) Shouldn't it be ...
<button type="button" class="btn btn-small btn-danger">
<i class=" icon-trash"></i>
</button>
Upvotes: 1