<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
<title>search animation</title>
</head>
<body>
<div class="search-box">
<input class="search-input" type="text" placeholder="Digita aqui">
<a href="#" class="search-btn">
<i class="fas fa-search"></i>
</a>
</div>
</body>
</html>
* {
padding: 0;
margin: 0;
}
body {
background-color: #e84118;
}
.search {
&-box {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #2f3640;
height: 40px;
border-radius: 40px;
padding: 10px;
}
&-btn {
color: #e84118;
float: right;
width: 40px;
height: 40px;
border-radius: 50%;
background: #2f3640;
display: flex;
justify-content: center;
align-items: center;
transition: 0.4s;
cursor: pointer;
}
&-input {
border: none;
background: none;
outline: none;
float: left;
color: white;
font-size: 16px;
transition: all .6s;
line-height: 40px;
width: 0px;
}
}
.search-box:hover > .search-input {
width: 400px;
padding: 0 6px;
}
.search-box:hover > .search-btn {
background: white;
color: black;
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.