how can I align font awesome icon in bootstrap button?

user5000215

I would like to ask for some help. I would like to align the font awesome icon in the middle of the button. Right now it only centers when I have an height of at least 50px.

This is what I am talking about:

enter image description here

Here is my css:

    .search {
      padding: 5px 0;
      width: 50px;
      height: 10px;
      position: relative;
      left: 10px;
      float: left;
      line-height: 22px;
    }

    .search input {
        position: absolute;
        width: 0px;
        float: Left;
        margin-left: 20px;
        -webkit-transition: all 0.7s ease-in-out;
        -moz-transition: all 0.7s ease-in-out;
        -o-transition: all 0.7s ease-in-out;
        transition: all 0.7s ease-in-out;
        height: 20px;
        line-height: 18px;
        padding: 0 2px 0 2px;
        border-radius:1px;
        top: 15px;

     }

     .search:hover input,
     .search input:focus {
        width: 100px;
        margin-left: 0px;
        z-index: 1000;
     }

    .btn {
      height: 20px;
      position: absolute;
      right: 0;
      top: 15px;
      border-radius:1px;
      z-index: 1001;

    }

here is the html:

  <!-- search -->    
  <div class="search">
    <input type="text" class="form-control input-sm" maxlength="64" placeholder="Search" />
    <button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-search"></i></button>
  </div>
  <!-- einde search -->

Can anyone help me out with my problem?

Thanks!

Kind Regards, Kevin.

Sebastian Brosch

You can set only padding-top:0; to the .btn and the icon is vertically centered.

Here a working fiddle: https://jsfiddle.net/sebastianbrosch/rw4eoz6b/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how can I align font awesome icon in bootstrap button?

From Dev

How can I use icon in drop down menu using Bootstrap and Font Awesome

From Dev

How can I use icon in drop down menu using Bootstrap and Font Awesome

From Dev

How do I get text below Icon button with font awesome

From Dev

Bootstrap 4 align Font Awesome icon horizontally and vertically

From Dev

How to add Font Awesome icon into <input> button?

From Dev

How can I align a button with the legend in bootstrap?

From Dev

Bootbox and Font awesome icon in button

From Dev

How do I insert a Font Awesome glyph/icon in a CakePHP submit button?

From Dev

How to vertically align font-awesome icons in a button?

From Dev

How to change button text to font awesome icon using jquery

From Dev

How to change button text to font awesome icon using jquery

From Dev

How to start spinning a bootstrap font awesome icon, then make it stop with jQuery

From Dev

How can I contain an icon from Font Awesome in a div element in CSS?

From Dev

Font Awesome - When stacking icons, how can I center the second icon

From Java

Can I change the color of Font Awesome's icon color?

From Dev

When appending a font awesome icon in a button using jQuery the icon disappears when I click another button

From Dev

How do I give a font awesome icon a background color?

From Dev

How do I decrease the size of a font-awesome icon?

From Dev

How do I add a Font Awesome icon to file input field

From Dev

Angular: How May I change Font Awesome icon and Text on condition

From Dev

CSS Awesome Font icon as submit button

From Dev

Font Awesome version 4 - Button with spin icon

From Dev

Font awesome icon and text in input submit button?

From Dev

Font awesome icon button with label below

From Dev

The icon conflict between bootstrap and font-awesome

From Dev

How can I align <label>,<input>, text, input fields, a real button, and a "<a> link button" properly and with the same font?

From Dev

How can I load a web font such as font awesome on page load?

From Dev

How to align list Items with font-awesome icon next line text?

Related Related

  1. 1

    how can I align font awesome icon in bootstrap button?

  2. 2

    How can I use icon in drop down menu using Bootstrap and Font Awesome

  3. 3

    How can I use icon in drop down menu using Bootstrap and Font Awesome

  4. 4

    How do I get text below Icon button with font awesome

  5. 5

    Bootstrap 4 align Font Awesome icon horizontally and vertically

  6. 6

    How to add Font Awesome icon into <input> button?

  7. 7

    How can I align a button with the legend in bootstrap?

  8. 8

    Bootbox and Font awesome icon in button

  9. 9

    How do I insert a Font Awesome glyph/icon in a CakePHP submit button?

  10. 10

    How to vertically align font-awesome icons in a button?

  11. 11

    How to change button text to font awesome icon using jquery

  12. 12

    How to change button text to font awesome icon using jquery

  13. 13

    How to start spinning a bootstrap font awesome icon, then make it stop with jQuery

  14. 14

    How can I contain an icon from Font Awesome in a div element in CSS?

  15. 15

    Font Awesome - When stacking icons, how can I center the second icon

  16. 16

    Can I change the color of Font Awesome's icon color?

  17. 17

    When appending a font awesome icon in a button using jQuery the icon disappears when I click another button

  18. 18

    How do I give a font awesome icon a background color?

  19. 19

    How do I decrease the size of a font-awesome icon?

  20. 20

    How do I add a Font Awesome icon to file input field

  21. 21

    Angular: How May I change Font Awesome icon and Text on condition

  22. 22

    CSS Awesome Font icon as submit button

  23. 23

    Font Awesome version 4 - Button with spin icon

  24. 24

    Font awesome icon and text in input submit button?

  25. 25

    Font awesome icon button with label below

  26. 26

    The icon conflict between bootstrap and font-awesome

  27. 27

    How can I align <label>,<input>, text, input fields, a real button, and a "<a> link button" properly and with the same font?

  28. 28

    How can I load a web font such as font awesome on page load?

  29. 29

    How to align list Items with font-awesome icon next line text?

HotTag

Archive