<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Animated Search Bar With Glowing Effect</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
<input type="text" placeholder="Search...">
<div class="search"></div>
</div>
</body>
</html>
*
{
margin: 0;
padding: 0;
box-sizing: border-box;
}
html,body
{
width: 100%;
height: 100%;
}
body
{
background: #111;
}
.container
{
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
margin: auto;
width: 300px;
height: 100px;
}
.search
{
position: absolute;
margin: auto;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 80px;
height: 80px;
background: #35d0ba;
border-radius: 50%;
z-index: 4;
box-shadow: 0 0 25px 0 rgba(0,0,0,0.4);
transition: all 1s;
}
.search:hover
{
cursor: pointer;
}
.search:before
{
content: '';
position: absolute;
margin: auto;
top: 30px;
right: 0;
bottom: 0;
left: 24px;
width: 20px;
height: 2px;
background: #fff;
transform: rotate(45deg);
transition: all 0.5s;
}
.search:after
{
content: '';
position: absolute;
margin: auto;
top: -5px;
width: 25px;
height: 25px;
left: -5px;
right: 0;
bottom: 0;
border: 4px solid #fff;
border-radius: 50%;
transition: all .5s;
}
input
{
font-family: monospace;
position: absolute;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 50px;
height: 50px;
outline: none;
border: none;
background: #35d0ba;
color: #fff;
padding: 0 80px 0 20px;
text-shadow: 0 0 10px #35d0ba;
border-radius: 30px;
box-shadow: 0 0 25px 0 #35d0ba, 0 20px 25px 0 rgba(0,0,0,.2);
z-index: 5;
font-weight: bold;
letter-spacing: 0.1em;
opacity: 0;
transition: all 1s;
}
input:hover
{
cursor: pointer;
}
input:focus
{
width: 300px;
opacity: 1;
cursor: text;
}
input:focus ~ .search
{
right: -250px;
background: #fff;
z-index: 8;
}
input:focus ~ .search:before
{
background: #111;
}
input:focus ~ .search:after
{
border: 4px solid #111;
}
input::placeholder
{
color: #fff;
font-weight: bold;
opacity: 0.5;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.