css+js实现按钮点击波纹扩散动画效果代码

代码语言:html

所属分类:动画

代码描述:css+js实现按钮点击波纹扩散动画效果代码

代码标签: 点击 波纹 扩散 动画 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<html>
<head>
    <style>
        body {
            position: relative;
            width: 100vw;
            height: 100vh;
            display: -webkit-box;
            display: flex;
            -webkit-box-align: center;
            align-items: center;
            -webkit-box-pack: center;
            justify-content: center;
            background: #55b9f3;
            color: #c8deeb;
            overflow: hidden;
        }

        #button {
            z-index: 10;
            position: absolute;
            width: 40px;
            height: 40px;
            background: #55b9f3;
            border-radius: 50%;
            box-shadow: 6px 6px 12px #489dcf, -6px -6px 12px #62d5ff;
            cursor: pointer;
        }
        #button svg {
            position: absolute;
            top: 50%;
            left: 50%;
            -webkit-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
        }
        #button.clicked {
            -webkit-animation: shadowFadeOut 200ms ease-out forwards, shadowFadeIn 200ms 300ms ease-in forwards;
            animation: shadowFadeOut 200ms ease-out forwards, shadowFadeIn 200ms 300ms ease-in forwards;
        }
        #button.clicked svg {
            -webkit-animation: fillFadeOut 200ms ease-out forwards, fillFadeIn 200ms 300ms ease-in forwards;
            animation: fillFadeOut 200ms ease-out forwards, fillFadeIn 200ms 300ms ease-in forwards;
        }

        .wave {
            z-index: 1;
            position: absolute;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            box-shadow: 20px 20px 60px #489dcf, -20px -20px 60px #62d5ff;
            opacity: 0;
            -webkit-animation: fadeIn 400ms ease-out forwards, outside_grow 5s ease-out, fadeOut 3s 2s forwards;
            animation: fadeIn 400ms ease-out forwards, outside_grow 5s ease-out, fadeOut 3s 2s forwards;
        }

        .wave::after {
            content: "";
            position: absolute;
            top: 50%;
            left: 50%;
            -webkit-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
            width: 0px;
            height: 0px;
            border-radius: 50%;
            box-shadow: inset 20px 20px 60px #489dcf, inset -20px -20px 60px #62d5ff;
            -webkit-animation: inside_grow 5s ease-out;
            animation: inside_grow 5s ease-out;
        }

@-webkit-keyframes outside_grow {
            from {
                width: 20px;
                height: 20px;
            }
            to {
                width: 900px;
                height: 900px;
            }
        }

@keyframes outside_grow {
            from {
                width: 20px;
                height: 20px;
            }
            to {
                width: 900px;
                height: 900px;
            }
        }
@-webkit-keyframes inside_grow {
            from {
                width: 0px;
                height: 0px;
            }
            to {
                width: 880px;
                height: 880px;
            }
        }
@keyframes inside_grow {
            from {
                width: 0px;
                height: 0px;
            }
            to {
                width: 880px;
                height: 880px;
            }
        }
@-webkit-keyframes fadeIn {
            from {
                opacity: 0;
            }
            to {
                opacity: 1;
            }
        }
@keyframes fadeIn {
            from {
                opacity: 0;
            }
            to {
                opacity: 1;
            }
        }
@-webki.........完整代码请登录后点击上方下载按钮下载查看

网友评论0