<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Search Box</title>
<link rel="stylesheet" href="dl.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body>
<h1 style="color: white;text-align: center;">Css Search Animation</h1>
<div class="search-box">
<input type="text" class="search-text" placeholder="Type to search">
<a href="#" class="search-btn">
<i class="material-icons">search</i>
</a>
</div>
</body>
</html>
body{
margin: 0;
padding: 0;
background: #000000;
}
.search-box{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #2f3640;
height: 40px;
border-radius: 40px;
padding: 10px;
}
.search-box:hover > .search-text{
width: 240px;
padding: 0px;
}
.search-box:hover > .search-btn{
background: white;
color: black;
}
.search-btn{
color: #fffdfd;
float: right;
width: 40px;
height: 40px;
border-radius: 50%;
background: #2f3640;
display: flex;
justify-content: center;
transition: 0.4s;
}
.search-text{
border: none;
background: none;
outline: none;
float: left;
padding: 0;
color: white;
font-size: 16px;
font-family: Arial, Helvetica, sans-serif;
transition: 0.4s;
line-height: 40px;
width: 0px;
}
.material-icons{
margin-top: 5px;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.