jQuery+CSS3点击水波动画竖直导航栏代码

作者 : 小刺猬 本文共1086个字,预计阅读时间需要3分钟 发布时间: 2020-07-30 共255人阅读

jQuery+CSS3点击水波动画竖直导航栏代码

一款简洁漂亮的基于jQuery+CSS3实现的带水波动画效果的竖直导航栏代码,鼠标点击导航菜单链接出现水波动画特效。

js代码

<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>
VIP免费 永久VIP免费

已有0人支付


刺猬源码 » jQuery+CSS3点击水波动画竖直导航栏代码

刺猬QQ交流群号多少?
363432
刺猬官方有技术支持吗?
有的,但技术支持是有偿服务哦,咨询右下角的在线客服吧!
下载的资源不能使用怎么办?
如果在本站下载的资源不能使用,一经确认可以联系在线客服退款。

发表评论

刺猬源码网,累计帮助1000+用户成功建站,为草根创业提供助力!

立即查看 了解详情