鼠标移入放大镜图标,逐渐显示搜索框
1) Add HTML
<!--使用Bootstrap字体图标-->
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="searchbar">
<form>
<input class="search-field">
<div class="search-btn glyphicon glyphicon-search"></div>
</form>
</div>
2) Add CSS
.searchbar {
position: absolute;
right: 200px;
top: 20px;
}
.search-field {
width: 37px;
height: 37px;
border: 1px solid #b08f4e;
background-color: rgba(176, 143, 78, 0.12);
outline: none;
padding-left: 20px;
transition:width 0.6s;
}
.search-btn {
background-color: #b08f4e;
width: 37px;
height: 37px;
position: absolute;
right: 0;
top: 0;
color: #fff;
font-size: 18px;
text-align: center;
line-height: 37px;
cursor: pointer;
}
.searchbar:hover .search-field {
width: 187px;
}