当鼠标激活文本框时,文本框自动加长,可以用在搜索框,当鼠标没点击时,文本框的宽度很窄,当激活时,自动伸长。以便输入更多的字符。
这可以用css3来实现。代码如下:
/* Search Form css3*/
.iptt{
list-style:none;
border:1px solid #d3d3d3;
background:url(../images/search.gif) center left no-repeat;
text-indent:22px;
}
.iptt{
-webkit-transition-duration: 400ms;
-webkit-transition-property: width, background;
-webkit-transition-timing-function: ease;
-moz-transition-duration: 400ms;
-moz-transition-property: width, background;
-moz-transition-timing-function: ease;
-o-transition-duration: 400ms;
-o-transition-property: width, background;
-o-transition-timing-function: ease;
width: 80px;/*这是起初的宽度*/
}
.iptt:focus {
background:url(../images/search.gif) center left no-repeat;
text-indent:22px;
list-style:none;
border:1px solid #d3d3d3;
width: 196px;/*这是要加长的宽度*/
}
只有在支持css3浏览器里才能看到效果。


