【发布时间】:2016-01-08 16:51:46
【问题描述】:
这是我的代码。
<style>
#searchformfix {
width: 50%;
border-right: 1px solid #E5E5E5;
border-left: 1px solid #E5E5E5;
position: relative;
background: #fff;
height: 40px;
display: inline-block;
border: 1px solid #219AEB;
border-radius: 5px;
margin-top: 5px;
}
#searchform {
margin: 0px 0 0;
padding: 0;
}
#searchform input[type="text"] {
background: #fff;
border: none;
float: left;
height: 100%;
transition: all 600ms cubic-bezier(0.215,0.61,0.355,1) 0s;
-moz-transition: all 300ms cubic-bezier(0.215,0.61,0.355,1) 0s;
-webkit-transition: all 600ms cubic-bezier(0.215,0.61,0.355,1) 0s;
-o-transition: all 600ms cubic-bezier(0.215,0.61,0.355,1) 0s;
color: #929292;
margin-left: 10px;
margin-top: 10px;
width: 80%;
}
button.fa.fa-search {
background: #FFF;
margin-top: 5px;
font-size: 24px;
float: right;
cursor: pointer;
}
</style>
<div id='searchformfix'>
<form action='/search' id='searchform'>
<input name='q' onblur='if (this.value == "") {this.value = "Search Videos...";}' onfocus='if (this.value == "Search Videos...") {this.value = "";}' type='text' value='Search Videos...'/></form>
<button class='fa fa-search' type='submit' value='Go'></button>
</div>
JsFiddle 演示:http://jsfiddle.net/jaribhai/wncwqerj/4/
所以这是一个有效的搜索栏。我想要做的是,它在桌面设备中仍然可见,并在像这样的移动设备中变得可扩展。
http://callmenick.com/_development/expanding-search-bar/
我认为如果不使用 Jquery 这是不可能的,所以有人告诉我如何才能获得这个功能。 谢谢
【问题讨论】:
标签: javascript jquery css searchbar