基于jQuery实现鼠标点击导航菜单水波动画效果附源码下载
2016-01-06 16:47
1451 查看
基于jQuery鼠标点击水波动画竖直导航代码。这是一款基于jQuery+CSS3实现的带动画效果的竖直导航栏特效。效果图如下:
html代码:
<div class="nav"> <ul> <li><a>网站首页</a></li> <li><a>关于我们</a></li> <li><a>产品中心</a></li> <li><a>成功案例</a></li> <li><a>联系我们</a></li> <li><a>在线留言</a></li> </ul> </div> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript"> //jQuery time var parent, ink, d, x, y; $(".nav ul li a").click(function (e) { parent = $(this).parent(); //create .ink element if it doesn't exist if (parent.find(".ink").length == 0) parent.prepend("<span class='ink'></span>"); ink = parent.find(".ink"); //incase of quick double clicks stop the previous animation ink.removeClass("animate"); //set size of .ink if (!ink.height() && !ink.width()) { //use parent's width or height whichever is larger for the diameter to make a circle which can cover the entire element. d = Math.max(parent.outerWidth(), parent.outerHeight()); ink.css({ height: d, width: d }); } //get click coordinates //logic = click coordinates relative to page - parent's position relative to page - half of self height/width to make it controllable from the center; x = e.pageX - parent.offset().left - ink.width() / 2; y = e.pageY - parent.offset().top - ink.height() / 2; //set the position and add class .animate ink.css({ top: y + 'px', left: x + 'px' }).addClass("animate"); }) </script>
以上代码是本文的核心代码,比较简单,大家可以根据需求,适当的添加删除代码。
您可能感兴趣的文章:
相关文章推荐
- JQuery1——基础($对象,选择器,对象转换)
- JavaScript演示排序算法
- 2015-2016网页设计趋势分析 Web Design of Trends
- jQuery Ajax 跨域调用
- 移动端的长按事件
- jquery教程靠边站,一分钱不花让你免费学会jquery
- JQuery+Strusts1.x无刷新登录
- JavaScript 各种遍历方式详解
- 数组方法汇总
- jQuery菜单插件用法实例
- JQuery 初体验(建议学习jquery)
- 基于Jquery和CSS3制作数字时钟附源码下载(CSS3篇)
- Jquery实现的table最后一行添加样式的代码
- jQuery实现向下滑出的平滑下拉菜单效果
- jQuery 练习[一] 学习jquery的准备工作
- jquery获得页面元素的坐标值实现思路及代码
- 使用Browserify配合jQuery进行编程的超级指南
- jquery如何实现在加载完iframe的内容后再进行操作
- jquery $.ajax()取xml数据的小问题解决方法
- jQuery '行 4954 错误: 不支持该属性或方法' 的问题解决方法