本效果适用于移动设备,可以使用手机等浏览效果。
html代码如下:
<!doctype html><html lang="zh"><head><meta charset="utf-8"><meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /><title>jquery+css3创意搜索框特效 - 何问起</title><link rel="stylesheet" type="text/css" href="http://hovertree.com/texiao/jquery/26/css/default.css" /><!--必要样式--><link rel="stylesheet" type="text/css" href="http://hovertree.com/texiao/jquery/26/css/search-form.css" /></head><body><p><a href="http://hovertree.com/">首页</a> <a href="http://hovertree.com/texiao/">特效</a> <a href="http://hovertree.com/h/bjaf/sousuokuang.htm">原文</a></p><form onsubmit="submitfn(this, event);" name="yestop"><p class="search-wrapper"><p class="input-holder"><input type="text" class="search-input" placeholder="请输入关键词" name="hewenqi" /><input type="hidden" name="q" /><button class="search-icon" onclick="searchtoggle(this, event);"><span></span></button></p><span class="close" onclick="searchtoggle(this, event);"></span><p class="result-container"></p></p></form><script src="http://hovertree.com/ziyuan/jquery/jquery-1.12.0.min.js" type="text/javascript"></script><script type="text/javascript" src="http://hovertree.com/texiao/jquery/26/js/hovertreesearch.js"></script></body></html>
其中hovertreesearch.js的代码如下:
function searchtoggle(obj, evt) {var container = $(obj).closest('.search-wrapper');if (!container.hasclass('active')) {container.addclass('active');evt.preventdefault();}else if (container.hasclass('active') && $(obj).closest('.input-holder').length == 0) {container.removeclass('active');// clear inputcontainer.find('.search-input').val('');// clear and hide result container when we press closecontainer.find('.result-container').fadeout(100, function () { $(this).empty(); });}}function submitfn(obj, evt) {var value = $(obj).find('.search-input').val().trim();var _html = "您搜索的关键词: ";if (!value.length) {_html = "关键词不能为空。";}else {window.open("http://cn.bi" + "ng.com/search?q=site%3ahove" + "rtree.com " + value + "&hewenqi=yestop");_html += "<b>" + value + "</b>";}$(obj).find('.result-container').html('<span>' + _html + '</span>');$(obj).find('.result-container').fadein(100);evt.preventdefault();}
以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注!
相关推荐:
html5 canvas和javascript如何实现本地截图
html5和css3以及jquery实现音乐播放器
以上就是html5和jquery实现弹出创意搜索框层的方法的详细内容。
