How to create an animated search form with CSS?

CSSWeb DevelopmentFront End Technology

Following is the code creates an animated search form with CSS −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
*{
   box-sizing: border-box;
}
input[type=text] {
   width: 170px;
   font-size: 16px;
   background-color: white;
   padding: 12px 20px 12px 40px;
   transition: width 0.4s ease-in-out;
}
input[type=text]:focus {
   width: 100%;
}
</style>
</head>
<body>
<h1>Animated search form example</p>
<form>
Search:
<input type="text" name="search" placeholder="Search Here...">
</form>
</body>
</html>

Output

This will produce the following output −

On clicking the search box −

raja
Published on 08-Apr-2020 14:34:38
Advertisements