效果图
1.html
<div class="searchBar">
<form action="" onsubmit="return false;">
<div class="searchImg">
<img src="img/search.png"/>
</div>
<input type="search" class="search" placeholder="输入关键字搜索" value=""/>
<span class="cancle">取消</span>
</form>
</div>
2.css
.searchBar{
height: 30px;
padding: 5px;
position: relative;
}
.searchImg{
display: inline-block;
background-color: #f5f5f5;
float: left;
width: 30px;
height: 30px;
position: absolute;
}
.searchImg img {
width: 16px;
height: 16px;
margin: 7px;
}
.search{
padding: 5px 0px 5px 30px;
background-color: #f5f5f5;
line-height: 30px;
height: 30px;
border: none;
box-sizing: border-box;
float: left;
width: calc(100% - 40px);
font-size: 13px;
border-radius: 3px;
}
.search:focus {
outline: none;
border: none;
}
.cancle{
display: inline-block;
height: 30px;
line-height: 30px;
width: 40px;
float: left;
text-align: center;
font-size: 13px;
color: cadetblue;
}