<div class="header">
<h1>Search</h1>
<span></span>
<input type="text" id="btn-search" class="material-icons" value="search" />
</div>
body {
font-family: 'Roboto', sans-serif;
background: #64FFDA;
}
.header {
display: flex;
align-items: center;
padding: 50px;
}
.header h1 {
font-size: 36px;
color: #00796B;
}
.header span { flex: 1; }
input[type="text"] {
border: none;
background: none;
height: 50px;
width: 50px;
font-size: 50px;
color: #00796B;
text-align: right;
outline: none;
cursor: pointer;
transition: width .3s;
}
input[type="text"]:focus {
font-family: 'Roboto', sans-serif;
font-size: 24px;
color: #000;
text-align: left;
width: 500px;
height: 10px;
padding: 20px;
border-radius: 0;
background: #fff;
box-shadow: 0 2px 10px 0 rgba(0,0,0,.16);
}
input[type="text"]:blur {
border: none;
background: none;
height: 50px;
width: 50px;
font-size: 50px;
color: #00796B;
text-align: right;
outline: none;
cursor: pointer;
transition: width .3s;
}
var btnSearch = document.getElementById('btn-search');
btnSearch.addEventListener('focus', function() {
btnSearch.value = '';
});
btnSearch.addEventListener('blur', function() {
btnSearch.value = 'search';
});
This Pen doesn't use any external JavaScript resources.