Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Font Awesome Icon inside input

I try the possible solutions posted here with this problem but no one works with my code, this is what I have

<div class="search">
  <span class="fa fa-user"></span>
  <input placeholder="Username...">
</div>
<div class="search">
   <span class="fa fa-lock"></span>
   <input placeholder="*******">
</div>

CSS

@import url("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css");
body { margin: 30px; }
.search {
   position: relative;
   color: #aaa;
   font-size: 16px;
}
.search input {
  width: 250px;
  height: 32px;
  background: #fcfcfc;
  border: 1px solid #aaa;
  border-radius: 5px;
  box-shadow: 0 0 3px #ccc, 0 10px 15px #ebebeb inset;
}
.search input { text-indent: 32px;}

I want the icon before the placeholder.

Here its the example code

like image 377
Francisco Fernandez Avatar asked Jan 24 '26 18:01

Francisco Fernandez


1 Answers

Try this, I just add some css to your icons.

.search .fa-user { 
        position: absolute;
        top: 10px;
        left: 10px;
    }

.search .fa-lock { 
        position: absolute;
        top: 10px;
        left: 10px;
    }

Here is your code updated

like image 139
Francisco Fernandez Avatar answered Jan 26 '26 09:01

Francisco Fernandez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!