I have a requirement where I need to design a search box with a search icon. I've written below HTML code and CSS class to achieve this. It is working fine on a 13" screen. But when screen resolution or size changes the search box and icon breaks.
<div class="col-sm-3 pull-right">
<div class="search-box">
<input type="text" class="portfolio-search-input" placeholder="Search by Benefit name" />
<span class="">
<i class="fa fa-search"></i>
</span>
</div>
</div>
.portfolio-search-input {
width: 85%;
height: 26px;
margin-top: 5px;
margin-left: 100px;
padding: 0 15px;
outline: none;
&:focus {
border: 1px solid;
}
}
.search-box {
position: relative;
clear: both;
> span {
color: rgb(209, 15, 15);
display: inline-block;
margin-left: 115%;
position: absolute;
bottom: 3px;
}
}
.pull-right {
float: right;
}
How can I fix the size and position irrespective of screen size/resolution.
On a 13" screen its working fine as per the below image.
But on bigger screen it breaks, as below.
If I am using margin-left:300px;, it works fine on 13" screen. On bigger screen it gives below image.



Remove
margin-leftfrom.search-box > span. And addright: 0.Remove
margin-leftfrom.portfolio-search-input. Add add that to.search-boxHere is the snippet