I'm trying to use the search icon from fontawesome instead of a background-image
in my search bar that uses a transition to expand the input area. Clicking on this icon the area should be opend.
I tried with
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<input type="text" name="eingabe" placeholder="Suche">
<i class="fa fa-search" aria-hidden="true"></i>
</input>
but then the symbol is beside the input and I can't click on it to use my transition to erase the width of my input.
@Saurav nearly solved my question, but I can't click on the icon.
.search-bar {
position: relative;
}
.search-bar .icon {
position: absolute;
top: 47%;
left: 10px;
transform: translateY(-50%);
}
.search-bar .input-text {
width: 0px;
border: 0px;
background-color: #fff;
height: 20px;
padding: 8px 8px 8px 35px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
}
.search-bar .input-text:focus {
width: 80%;
background-color: #ccc;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="search-bar">
<i class="icon fa fa-search"></i>
<input class="input-text" type="text" name="eingabe" placeholder="Suche">
</div>