<!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">
<title>Search Animation</title>
<link rel="stylesheet" href="SearchAnimation.css">
</head>
<body>
<div class="container">
<div class="search">
<span></span>
<input type="text">
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$('span').click(function(){
$('.container').toggleClass('active');
$('input').toggleClass('active');
$('span').toggleClass('active');
});
</script>
</body>
</html>
.container,input,span {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
.container,input,span,span::before{transition: .4s;}
.container {
width: 100px;
height: 100px;
background: dodgerblue;
border-radius: 100%;
overflow: hidden;
}
input{
font-family: verdana;
font-size: 1.3em;
color: white;
width: 35px;
height: 35px;
background: transparent;
border-radius: 100%;
z-index: -1;
border: 0px solid white;
}
span {
background: transparent;
width: 35px;
height: 35px;
border-radius: 100%;
border: 3px solid white;
}
span::before {
content: "";
position: absolute;
width: 3px;
background: white;
height: 20px;
top: 28px;
left: 35px;
transform: rotate(-45deg);
z-index: 3;
}
.search{cursor: pointer;}
.container.active {
width: 100%;
height: 100vh;
border-radius: 0px;
}
span.active {
transform: scale(.6);
margin-left: 130px;
margin-top: -20px;
}
input.active {
width: 300px;
height: 50px;
border-width: 3px;
border-radius: 40px;
padding: 0 50px 0 10px;
outline: none;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.