Here i have explained how to create an animated search form with CSS.

Step1: copy the following HTML Markup and paste it inside body tag.

HTML Markup

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

Step2: copy the following CSS and paste it inside head tag.

CSS

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%;
}

Screenshot

Add Comments