SVG 3秒倒计时

2017-07-12  本文已影响0人  wyq_0bed
<!doctype html>
<html>

    <head>
        <meta charset="utf-8">
        <title>Gooey倒计时</title>

        <style>
            *,
            *::before,
            *::after {
                margin: 0;
                padding: 0;
                box-sizing: inherit;
            }
            
            body {
                display: -webkit-box;
                display: -ms-flexbox;
                display: flex;
                box-sizing: border-box;
                background-color: hsl(210, 5%, 12%);
            }
            
            svg {
                margin: auto;
                width: 100vmin;
            }
            
            g > text {
                text-anchor: middle;
                font-size: 400px;
                font-family: Overpass Mono, monospace;
                fill: hsl(210, 100%, 75%);
                opacity: 0;
                -webkit-animation-name: opac;
                animation-name: opac;
                -webkit-animation-duration: 11s;
                animation-duration: 11s;
                -webkit-animation-timing-function: linear;
                animation-timing-function: linear;
                -webkit-animation-iteration-count: infinite;
                animation-iteration-count: infinite;
            }
            
            g > text:nth-child(1) {
                -webkit-animation-delay: 0s;
                animation-delay: 0s;
            }
            
            g > text:nth-child(2) {
                -webkit-animation-delay: 1s;
                animation-delay: 1s;
            }
            
            g > text:nth-child(3) {
                -webkit-animation-delay: 2s;
                animation-delay: 2s;
            }
            
            g > text:nth-child(4) {
                -webkit-animation-delay: 3s;
                animation-delay: 3s;
            }
            
            @-webkit-keyframes opac {
                0% {
                    opacity: 0;
                }
                7.5% {
                    opacity: 1;
                }
                10% {
                    opacity: 1;
                }
                15% {
                    opacity: 0;
                }
                100% {
                    opacity: 0;
                }
            }
            
            @keyframes opac {
                0% {
                    opacity: 0;
                }
                7.5% {
                    opacity: 1;
                }
                10% {
                    opacity: 1;
                }
                15% {
                    opacity: 0;
                }
                100% {
                    opacity: 0;
                }
            }
        </style>
    </head>

    <body>

        <svg viewBox="-500 -500 1000 1000" width="100%" height="100%" preserveAspectRatio="xMidYMin slice">
  <defs>
    <filter id="goo">
      <feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur"></feGaussianBlur>
      <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 20 -5" result="goo"></feColorMatrix>
      <feComposite in="SourceGraphic" in2="goo" operator="atop"></feComposite>
    </filter>
  </defs>
  <circle fill="hsla(0, 100%, 50%, 0.25)" cx="0" cy="0" r="300"></circle>
  <g filter="url(#goo)">
    <text x="0" y="150">3</text>
    <text x="0" y="150">2</text>
    <text x="0" y="150">1</text>
    <text x="0" y="150">GO</text>
  </g>
</svg>

    </body>

</html>
上一篇下一篇

猜你喜欢

热点阅读