效果體驗:http://hovertree.com/texiao/jquery/26/本效果適用於移動設備,可以使用手機等瀏覽效果。代碼下載:http://hovertree.com/h/bjaf/e14uccpw.htmHTML代碼如下: 1 <!doctype html> 2 <html lan
效果體驗:http://hovertree.com/texiao/jquery/26/
本效果適用於移動設備,可以使用手機等瀏覽效果。
代碼下載:http://hovertree.com/h/bjaf/e14uccpw.htm
HTML代碼如下:
1 <!doctype html> 2 <html lang="zh"> 3 <head> 4 <meta charset="UTF-8"> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 6 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> 7 <title>jQuery+CSS3創意搜索框特效 - 何問起</title> 8 <link rel="stylesheet" type="text/css" href="http://hovertree.com/texiao/jquery/26/css/default.css" /> 9 <!--必要樣式--> 10 <link rel="stylesheet" type="text/css" href="http://hovertree.com/texiao/jquery/26/css/search-form.css" /> 11 12 </head> 13 <body> 14 <div> 15 <a href="http://hovertree.com/">首頁</a> <a href="http://hovertree.com/texiao/">特效</a> <a href="http://hovertree.com/h/bjaf/sousuokuang.htm">原文</a> 16 </div> 17 <form onSubmit="submitFn(this, event);" name="yestop"> 18 <div class="search-wrapper"> 19 <div class="input-holder"> 20 <input type="text" class="search-input" placeholder="請輸入關鍵詞" name="hewenqi" /> 21 <input type="hidden" name="q" /> 22 <button class="search-icon" onClick="searchToggle(this, event);"><span></span></button> 23 </div> 24 <span class="close" onClick="searchToggle(this, event);"></span> 25 <div class="result-container"> 26 27 </div> 28 </div> 29 </form> 30 31 <script src="http://hovertree.com/ziyuan/jquery/jquery-1.12.0.min.js" type="text/javascript"></script> 32 <script type="text/javascript" src="http://hovertree.com/texiao/jquery/26/js/hovertreesearch.js"></script> 33 </body> 34 </html>
其中hovertreesearch.js的代碼如下:
1 function searchToggle(obj, evt) { 2 var container = $(obj).closest('.search-wrapper'); 3 4 if (!container.hasClass('active')) { 5 container.addClass('active'); 6 evt.preventDefault(); 7 } 8 else if (container.hasClass('active') && $(obj).closest('.input-holder').length == 0) { 9 container.removeClass('active'); 10 // clear input 11 container.find('.search-input').val(''); 12 // clear and hide result container when we press close 13 container.find('.result-container').fadeOut(100, function () { $(this).empty(); }); 14 } 15 } 16 17 function submitFn(obj, evt) { 18 var value = $(obj).find('.search-input').val().trim(); 19 20 var _html = "您搜索的關鍵詞: "; 21 if (!value.length) { 22 _html = "關鍵詞不能為空。"; 23 } 24 else { 25 window.open("http://cn.bi" + "ng.com/search?q=site%3Ahove" + "rtree.com " + value + "&hewenqi=yestop"); 26 _html += "<b>" + value + "</b>"; 27 } 28 29 $(obj).find('.result-container').html('<span>' + _html + '</span>'); 30 $(obj).find('.result-container').fadeIn(100); 31 32 evt.preventDefault(); 33 }
更多特效:http://www.cnblogs.com/roucheng/p/texiao.html