点击波浪加滑动描边

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JS</title>
    <script src="https://cdn.bootcss.com/jquery/3.4.0/jquery.min.js"></script>
    <style type="text/css" media="screen">
        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-keyframes rippleDrop {
            100% {
                -webkit-transform: scale(2);
                transform: scale(2);
                opacity: 0;
            }
        }

        @keyframes rippleDrop {
            100% {
                -webkit-transform: scale(2);
                transform: scale(2);
                opacity: 0;
            }
        }
    </style>
</head>

<body>
    <ul>
        <li>Tab One</li>
        <li>Tab Two</li>
        <li>Tab Three</li>
        <li class="slider"></li>
    </ul>
</body>
<script>
    $("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).append("<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");

    });
</script>

</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值