jQuery可伸缩搜索框代码实例
分类:实例代码
分享一段代码实例,它实现了可伸缩搜索框效果。
代码实例如下:
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.pipipi.net/" /> <title>前端教程网</title> <style type="text/css"> * { margin: 0; padding: 0; } body { margin: 0 auto; background-color: #333; } .search { width: 510px; margin: 0 auto; margin-top: 225px; } .q { width: 300px; height: 75px; line-height: 75px; float: right; border-radius: 25px; text-indent: 1em; font-size: 25px; color: #336699; } .sub { width: 75px; height: 79px; line-height: 79px; float: right; border-radius: 10px; font-size: 25px; color: #336699; cursor: pointer; } </style> <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script> <script> $(document).ready(function () { $(".q").mouseover(function () { $(this).animate({ width: '425px' }, 500); }); $(".q").focusout(function () { $(this).animate({ width: '300px' }, 500); }); }); </script> </head> <body> <div class="search"> <form> <input type="submit" name="search" value="GO" class="sub" /> <input type="text" name="search" class="q" value="前端教程网欢迎您" /> </form> </div> </body> </html>
jQuery可伸缩搜索框代码实例,这样的场景在实际项目中还是用的比较多的,关于jQuery可伸缩搜索框代码实例就介绍到这了。
jQuery可伸缩搜索框代码实例属于前端实例代码,有关更多实例代码大家可以查看。