To place an element with position: absolute
usually we need to add position: relative
on parent element. As from Documentation:
The absolutely positioned element is positioned relative to nearest positioned ancestor (non-static). If a positioned ancestor doesn't exist, the initial container is used.
I would suggest you to use a bit modified HTML
as shown below:
<div class="input-holder">
<input type="text" class="search_location" value="Choose Location">
<i class="fa fa-map-marker icon"></i>
</div>
With some following changes in css:
* {box-sizing: border-box;}
.input-holder {
position: relative;
width: 300px;
}
.search_location {
display: block;
width: 100%;
}
* {box-sizing: border-box;}
.input-holder {
position: relative;
width: 300px;
}
.search_location {
padding: 9px 10px 8px 10px;
background: #fff;
display: block;
color: #777;
width: 100%;
}
.icon {
position: absolute;
right: 10px;
top: 10px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="input-holder">
<input type="text" class="search_location" value="Choose Location">
<i class="fa fa-map-marker icon"></i>
</div>