|
搜索条在我们网站是必不可少的,尤其是在有限的页面空间里,放置一个重要的搜索条是个难题,今天我将结合实例给大家介绍一下如何使用CSS3和jQuery来实现一个可伸缩功能的搜索条。
HTML
在需要放置搜索条的页面中放置如下html代码,搜索条#search_bar包含一个form#myform表单,表单中放置一个搜索输入框#search,一个搜索按钮.search_btn以及搜索按钮图标.search_ico。
<div id="search_bar" class="search_bar"> <form id="myform"> <input class="input" placeholder="想搜点什么呢..." type="text" name="key" id="search"> <input class="search_btn" type="submit" value=""> <span class="search_ico"></span> </form> </div>
CSS
我们通过CSS来将整个搜索条布局美化,其中我们使用了CSS3代码。
.search_bar{position: relative;margin-top: 10px; width: 0%;min-width: 60px;height: 60px; float: right;overflow: hidden; -webkit-transition: width 0.3s; -moz-transition: width 0.3s; transition: width 0.3s; -webkit-backface-visibility: hidden; background:#162934; } .input{ position: absolute;top: 0;right: 0; border: none;outline: none; width: 98%;height: 60px; line-height:60px;z-index: 10; font-size: 20px;color: #f9f9f9;background:transparent } .search_ico,.search_btn { width: 60px;height: 60px;display: block; position: absolute;right: 0;top: 0; padding: 0;margin: 0;line-height: 60px;cursor: pointer; } .search_ico{background: #e67e22 url(icon.png) no-repeat 18px 20px;z-index:90;} .search_open{width: 100% !important; z-index:1002} #show{position:absolute; padding:20px}
(编辑:佛山站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|