Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align bootstrap icon with text in button?

How to align bootstrap icon and image to bottom? ( I am using font-awsome for icons ).

JSBIN: http://jsbin.com/uwupuz/2/edit

enter image description here

<div class="btn-group"> 
    <a class="btn" href="#">
      <i class="icon-plus"></i>
      <span>Add</span>
    </a>
    <a class="btn" href="#">
        <i class="icon-trash"></i>
        <span>Remove</span>
    </a>
    <a class="btn" href="#">
      <i class="icon-edit"></i>
      <span>Edit</span>
    </a>
  </div>
like image 235
SunnyShah Avatar asked Jan 16 '13 19:01

SunnyShah


People also ask

How do I align text and icons in one line?

If you want to make a text appear vertically aligned next to a Font Awesome icon, you can use the CSS vertical-align property set to “middle” and also, specify the line-height property. Change the size of the icon with the font-size property.

How do I center align an icon in Bootstrap?

Put the font awesome icon into a separate div and apply "text-center" class. It will align font-awesome icons to center.

How do I align text in a button in CSS?

We can align the buttons horizontally as well as vertically. We can center the button by using the following methods: text-align: center - By setting the value of text-align property of parent div tag to the center. margin: auto - By setting the value of margin property to auto.

How do I align a button to the right side of a text box in Bootstrap?

Answer: Use the text-right Class You can simply use the class . text-right on the containing element to right align your Bootstrap buttons within a block box or grid column. It will work in both Bootstrap 3 and 4 versions.


1 Answers

Try this: http://jsfiddle.net/jonschlinkert/CBss2/1/ this is what it looks like after applying line-height: 1;

button screen cap

I wouldn't mess with the position property as suggested by @hajpoj, there are cleaner ways to fix the problem that won't have cascading effects later. The other problem with using position: relative is that each icon is actually a little bit different in size. You want to try to keep maintenance down by accounting for that. It's best to make it appear as if it's bottom-aligned for most normal sized icons, and when a larger-than-average icon is used it is centered properly with the text. Using position: relative a larger icon will push above the others and look off-center.

like image 103
jonschlinkert Avatar answered Oct 10 '22 16:10

jonschlinkert