Expanding input box using only css - HTML CSS CSS Form

HTML CSS examples for CSS Form:input

Description

Expanding input box using only css

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
form {<!--from ww  w  .j  a  va 2s .c  om-->
   display:table;
   width:100%;
}

span {
   display:table-cell;
   text-align:right;
}

span:first-child {
   width:100%;
}

input[type='text'] {
   box-sizing:border-box;
   -webkit-transition:width 2s;
   -moz-transition:width 2s;
   transition:width 2s;
   width:51%;
   height:31px;
}

input[type='text']:focus {
   width:100%;
}

input[type='submit'] {
   background:Chartreuse;
   background:-webkit-linear-gradient(top, yellow 0%, blue 100%);
   background:-moz-linear-gradient(top, pink 0%, OrangeRed 100%);
   background:linear-gradient(top, grey 0%, BlueViolet 100%);
   color:Chartreuse;
   border-radius:0;
   border:0;
   width:81px;
   height:31px;
}
</style> 
 </head> 
 <body> 
  <header> 
   <form method="get" action="/search"> 
    <span> <input class="clearable" type="text" value="ipad" name="q" autocomplete="off"> </span> 
    <span> <input type="submit" value="Search"> </span> 
   </form> 
  </header>  
 </body>
</html>

Related Tutorials