button特效

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			*{padding: 0px;margin: 0px;}
			.wrap{width: 80%;margin: 50px auto;}
			ul{list-style: none;font-size: 14px;position: relative;}
			ul li{position:relative;float: left;padding: 10px 25px;cursor: pointer;margin-right: 5px;z-index: 1;}
			.slider{position: absolute;top: 0px;width: 0px;background: #46c0b3;z-index: 0;}
			ul li:after{content: "";
			    position: absolute;
			    left: 50%;
			    bottom: -2px;
			    width: 100%;
			    border-bottom: 2px solid #333;
			    -webkit-transform: translate(-50%) scaleX(0);
			    transform: translate(-50%) scale(0);
			    transition: .2s ease-in-out;}
				ul li:hover:after{-webkit-transform: translate(-50%) scaleX(1);transform: translate(-50%) scale(1);}
				
			/*鼠标点击类*/
			.ripple{
				position: absolute;
				opacity: 1;
				width: 0px;
				height: 0px;
				border-radius: 50%;
				background: rgba(255,255,255,0.7);
				-webkit-transform: scale(0);
				-moz-transform: scale(0);
				transform: scale(0);
			}
			.rippleEffect{
				-webkit-animation: rippleDrop 0.6s linear;
				animation: rippleDrop 0.6s linear;
			}
			@-webkit-keyframes rippleDrop{
				to{
					-webkit-transform: scale(2);
					transform: scale(2);
					opacity: 0;
				}
			}

		</style>
	</head>
	<body>
		<div class="wrap">
			<ul>
				<li>菜单一</li>
				<li>菜单二</li>
				<li>菜单三</li>
				<li>菜单四</li>
				<li>菜单五</li>
				<li>菜单六</li>
				<div class="slider"></div>
			</ul>
		</div>
		<script src="js/jquery-1.11.2.min.js"></script>
		<script type="text/javascript">
			$("ul li").hover(function(e) {
				var w=$(this).outerWidth();
				var h=$(this).outerHeight();
				$(".slider").css({
					width:w+'px',
					height:h+'px',
				});
				var whatTab = $(this).index();
				var howFar = (w+5) * whatTab;
				$('.slider').animate({
					left: howFar + "px"
				},'fast');
			});
			$("ul li").click(function(e) {
				$(".ripple").remove();
				// Setup
				var posX = $(this).offset().left,
					posY = $(this).offset().top,
					buttonWidth = $(this).width(),
					buttonHeight = $(this).height();
				// Add the element
				$(this).prepend("<span class='ripple'></span>");
				// Make it round!
				if(buttonWidth >= buttonHeight) {
					buttonHeight = buttonWidth;
				} else {
					buttonWidth = buttonHeight;
				}
				// Get the center of the element
				var x = e.pageX - posX - buttonWidth / 2;
				var y = e.pageY - posY - buttonHeight / 2;
				// Add the ripples CSS and start the animation
				$(".ripple").css({
					width: buttonWidth,
					height: buttonHeight,
					top: y + 'px',
					left: x + 'px'
				}).addClass("rippleEffect");
			});
			</script>
	</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值