html文件代码如下:
<!DOCTYPE html>
<html>
<head>
< http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
< >RunJS</ >
< id=\"jquery_183\" type=\"text/ \" class=\"library\" src=\"/js/sandbox/jquery/jquery-1.8.3.min.js\"></ >
<!--
版权声明:复制一个老外网站的代码
-->
</head>
<body>
<ul>
<li>Tab One</li>
<li>Tab Two</li>
<li>Tab Three</li>
<li class=\"slider\"></li>
</ul>
</body>
</html>
css代码如下:
ul {
font-size: 0;
position: relative;
padding: 0;
width: 480px;
margin: 40px auto;
user-select: none;
}
li {
display: inline-block;
width: 160px;
height: 60px;
background: #E95546;
font-size: 16px;
text-align: center;
line-height: 60px;
color: #fff;
text-transform: uppercase;
position: relative;
overflow: hidden;
cursor: pointer;
}
.slider {
display: block;
position: absolute;
bottom: 0;
left: 0;
height: 4px;
background: #4FC2E5;
transition: all 0.5s;
}
.ripple {
width: 0;
height: 0;
border-radius: 50%;
background: rgba(255, 255, 255, 0.4);
-webkit-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
position: absolute;
opacity: 1;
}
.rippleEffect {
-webkit-animation: rippleDrop .4s linear;
animation: rippleDrop .4s linear;
}
@-webkit-key s
rippleDrop { 100% {
-webkit-transform: scale(2);
transform: scale(2);
opacity: 0;
}
}
@key s
rippleDrop { 100% {
-webkit-transform: scale(2);
transform: scale(2);
opacity: 0;
}
}
js代码如下:
$(\"ul li\").click(function(e) {
if ($(this).hasClass(\'slider\')) {
return;
}
var whatTab = $(this).index();
var howFar = 160 * whatTab;
$(\".slider\").css({
left: howFar + \"px\"
});
$(\".ripple\").remove();
var posX = $(this).offset().left,
posY = $(this).offset().top,
buttonWidth = $(this).width(),
buttonHeight = $(this).height();
$(this).prepend(\"<span class=\'ripple\'></span>\");
if (buttonWidth >= buttonHeight) {
buttonHeight = buttonWidth;
} else {
buttonWidth = buttonHeight;
}
var x = e.pageX - posX - buttonWidth / 2;
var y = e.pageY - posY - buttonHeight / 2;
$(\".ripple\").css({
width: buttonWidth,
height: buttonHeight,
top: y + \'px\',
left: x + \'px\'
}).addClass(\"rippleEffect\");
});
继续阅读与本文标签相同的文章
-
非标自动化设备开发流程PPT,讲的太直观了!
2026-05-15栏目: 教程
-
商侃高清美图
2026-05-15栏目: 教程
-
任正非放话了:想要5G技术?来买吧!德国、英国赚大了,波兰怎么办?
2026-05-15栏目: 教程
-
中国第一封电子邮件1987年9月14日从北京发往德国历时6天
2026-05-15栏目: 教程
-
国产最强纯电SUV上市,24.96万起,全面碾压特斯拉!
2026-05-15栏目: 教程
