HTML Form How to - Expand Search box CSS3








Question

We would like to know how to expand Search box CSS3.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
body {<!--  w  w w .  jav a 2s .c  o  m-->
  background: #333;
}

input[type=text] {
  width: 100px;
  padding: 4px 8px;
  color: #ccc;
  background: #666;
  font-size: 12px;
  border-radius: 20px;
  border: none;
  box-shadow: inset 0px 1px 0 #222;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  float: right;
  -webkit-transition: all ease-in-out .3s;
}

input[type=text]:focus {
  width: 165px;
  outline: none;
  background: white;
  box-shadow: none;
  border-bottom-color: transparent;
  color: #666;
}
</style>
</head>
<body>
  <input type="text" value="Search">
</body>
</html>

The code above is rendered as follows: