隐藏

css3按钮波纹效果

发布:2020/11/26 9:11:38作者:管理员 来源:本站 浏览次数:1198

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        #box{
          width: 200px;
          height: 60px;
          margin: 50px auto;
          padding: 5px 0 0 10px;
          position: relative;
        }
        #box .btn{
          width: 150px;
          height: 40px;
          line-height: 40px;
          border-radius: 30px;
          background: #26bfc5;
          cursor: pointer;
          text-align: center;
          color: #fff;
          z-index: 10;
        }
        .dot {
          width: 150px;
          height: 40px;
          top:5px;
          left:10px;
          border-radius: 30px;
          position: absolute;
          z-index: -10;
          animation: sploosh 2s cubic-bezier(0.165, 0.84, 0.44, 1);
          background: transparent;
        }
        @keyframes sploosh {
          0% {
            box-shadow: 0 0 0 0px rgba(38, 191, 197, 0.5);
            background: rgba(38, 191, 197, 0.5);
          }
          100% {
            box-shadow: 0 0 0 20px rgba(38, 191, 197, 0);
            background: rgba(38, 191, 197, 0);
          }
        }
    </style>
</head>
<body>
    <div id="box">
        <div class="btn">点击</div>
    </div>

    <script src="js/jquery-1.12.3.min.js"></script>
    <script>
        $(function(){
            $("#box .btn").click(function(){
                    setTimeout(function () {
                        $('#box').append('<div class="dot"></div>')
                    }, 300);
                    setTimeout(function () {
                        $('#box').append('<div class="dot"></div>')
                    }, 0);
                    setTimeout(function () {
                        $('#box .dot').remove();
                    }, 2000);
                });
        })
    </script>
</body>
</html>