How TO – Animated Search Form


Previous


Next

Learn how to create an animated search form with CSS.


How To Create an Animated Search Form

Click on the input field:


Step 1) Add HTML:

Example

<input type=”text” name=”search” placeholder=”Search..”>

Step 2) Add CSS:

Example

<!DOCTYPE html>
<html>
<head>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<style>
input[type=text] {
width: 130px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-image: url(‘searchicon.png’);
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
}

input[type=text]:focus {
width: 100%;
}
</style>
</head>
<body>

<p>Animated search form:</p>

<form>
<input type=”text” name=”search” placeholder=”Search..”>
</form>

</body>
</html>


Previous


Next

Scroll to Top