Apple.com の伸縮性のある検索ボックスをフォーカスして再作成しようとしています。私はそれを機能させましたが、私のものは背景画像を伸ばし、虫眼鏡が伸びずに縫い目が優雅に追加されるようにします。また、ある背景を別の背景にフェードさせることもできました。
ここに私のCSSがあります
#header input {
background:url(http://www.golfbrowser.com/images/icons/search.png) no-repeat top right;
padding:2px;
margin-top:8px;
margin-right:10px;
padding-left:18px;
font-family:"Lucida Grande", Arial, sans-serif;
font-size:12px;
color:#222;
border:0px;
background-color:none;
float:right;
width:140px;
background-size:160px 20px;
}
#header input:focus {
background:url(http://www.golfbrowser.com/images/icons/search-z.png) no-repeat top right;
transition: width 0.5s, background-size 0.5s, background 0.5s;
-moz-transition: width 0.5s, background-size 0.5s, background 0.5s;
-webkit-transition: width 0.5s, background-size 0.5s, background 0.5s;
-o-transition: width 0.5s, background-size 0.5s, background 0.5s;
width:180px;
background-size:200px 20px;
}
#header input:blur {
transition: width 2s;
-moz-transition: width 2s; /* Firefox 4 */
-webkit-transition: width 2s; /* Safari and Chrome */
-o-transition: width 2s;
width:140px;
background-size:160px 20px;
}