gsap+svg实现带数字过渡动画的幻灯片效果代码

代码语言:html

所属分类:幻灯片

代码描述:gsap+svg实现带数字过渡动画的幻灯片效果代码

代码标签: gsap svg 幻灯片

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

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">



    <style>
        @font-face {
          font-family: Cyber;
          src: url("//repo.bfw.wiki/bfwrepo/fonts/Blender-Pro-Bold.otf");
          font-display: swap;
        }
        * {
          box-sizing: border-box;
        }
        :root {
          --size: 300px;
        }
        body {
          min-height: 100vh;
          display: grid;
          place-items: center;
          --primary: hsl(58, 100%, calc((48 - var(--lightness, 0)) * 1%));
          --secondary: hsl(58, 100%, calc((45 - var(--lightness, 0)) * 1%));
          background: linear-gradient(90deg, var(--primary) 70%, var(--secondary) 70%), var(--primary);
          overflow: hidden;
        }
        ul {
          height: var(--size);
          aspect-ratio: 1/1;
          list-style-type: none;
          padding: 0;
          margin: 0;
          position: relative;
          -webkit-clip-path: polygon(0 0, 100% 0, 100% 100%, 90% 100%, 90% 95%, 70% 95%, 70% 100%, 10% 100%, 0 90%);
          clip-path: polygon(0 0, 100% 0, 100% 100%, 90% 100%, 90% 95%, 70% 95%, 70% 100%, 10% 100%, 0 90%);
          border-right: 6px solid #3df5f5;
        }
        li {
          position: relative;
        }
        li,
        img {
          height: 100%;
          width: 100%;
          position: absolute;
        }
        img {
          position: absolute;
          left: 0;
          top: 0;
          background-size: cover;
          clip-path: var(--clip);
          -webkit-clip-path: var(--clip);
        }
        svg {
          height: var(--size);
          width: var(--size);
          position: absolute;
        }
        .direction-button {
          position: absolute;
          top: 50%;
          transform: translate(calc(var(--offset) * 50%), -50%);
        }
        .direction-button--next {
          --offset: 1;
          left: 100%;
        }
        .direction-button--prev {
          --offset: -1;
          right: 100%;
        }
        .cybr-sldr {
          display: none;
          position: relative;
          height: var(--size);
          aspect-ratio: 1/1;
          background: linear-gradient(90deg, transparent 0 15%, #3df5f5 15% 72%, transparent 72%);
          font-family: 'Cyber', sans-serif;
        }
        .cybr-sldr > .cybr-btn__tag {
          bottom: 0;
          left: 72%;
          transform: translate(0, 15%);
        }
        .cybr-btn {
          --primary: hsl(var(--primary-hue), 85%, calc(var(--primary-lightness, 50) * 1%));
          --shadow-primary: hsl(var(--shadow-primary-hue), 90%, 50%);
          --primary-hue: 0;
          --primary-lightness: 50;
          --color: #fff;
          --font-size: 26px;
          --shadow-primary-hue: 180;
          --label-size: 9px;
          --shadow-secondary-hue: 60;
          --shadow-secondary: hsl(var(--shadow-secondary-hue), 90%, 60%);
          --clip: polygon(0 0, 100% 0, 100% 100%, 95% 100%, 95% 90%, 55% 90%, 55% 100%, 18% 100%, 0 82%);
          --border: 4px;
          --shimmy-distance: 5;
          --clip-one: polygon(0 2%, 100% 2%, 100% 95%, 95% 95%, 95% 90%, 55% 90%, 55% 95%, 18% 95%, 0 82%);
          --clip-two: polygon(0 78%, 100% 78%, 100% 100%, 95% 100%, 95% 90%, 55% 90%, 55% 100%, 16% 100%, 0 78%);
          --clip-three: polygon(0 44%, 100% 44%, 100% 54%, 95% 54%, 95% 54%, 55% 54%, 55% 54%, 18% 54%, 0 54%);
          --clip-four: polygon(0 0, 100% 0, 100% 0, 95% 0, 95% 0, 55% 0, 55% 0, 18% 0, 0 0);
          --clip-five: polygon(0 0, 100% 0, 100% 0, 95% 0, 95% 0, 55% 0, 55% 0, 18% 0, 0 0);
          --clip-six: polygon(0 40%, 100% 40%, 100% 85%, 95% 85%, 95% 85%, 55% 85%, 55% 85%, 18% 85%, 0 82%);
          --clip-seven: polygon(0 63%, 100% 63%, 100% 80%, 95% 80%, 95% 80%, 55% 80%, 55% 80%, 18% 80%, 0 82%);
          font-family: 'Cyber', sans-serif;
          color: var(--color);
          cursor: pointer;
          background: transparent;
          text-transform: uppercase;
          font-size: var(--font-size);
          outline: transparent;
          letter-spacing: 2px;
          position: absolute;
          font-weight: 700;
          border: 0;
          width: 75px;
          height: 75px;
          line-height: 75px;
          transition: background 0.2s;
        }
        .cybr-btn:hover {
          --primary: hsl(var(--primary-hue), 85%, calc(var(--primary-lightness, 50) * 0.8%));
        }
        .cybr-btn:active {
          --primary: hsl(var(--primary-hue), 85%, calc(var(--primary-lightness, 50) * 0.6%));
        }
        .cybr-btn:after,
        .cybr-btn:before {
          content: '';
          position: absolute;
          top: 0;
          left: 0;
          right: 0;
          bottom: 0;
          -webkit-clip-path: var(--clip);
                  clip-path: var(--clip);
          z-index: -1;
        }
        .cybr-btn:before {
          background: var(--shadow-primary);
          transform: translate(var(--border), 0);
        }
        .cybr-btn:after {
          background: var(--primary);
        }
        .cybr-btn__tag {
          position: absolute;
          padding: 1px 4px;
          letter-spacing: 1px;
          line-height: 1;
          bottom: -5%;
          right: 5%;
          font-weight: normal;
          color: #000;
          font-size: var(--label-size);
        }
        .cybr-btn__glitch {
          position: absolute;
          top: calc(var(--border) * -1);
          left: calc(var(--border) * -1);
          right: calc(var(--border) * -1);
          bottom: calc(var(--border) * -1);
          background: var(--shadow-primary);
          text-shadow: 2px 2px var(--shadow-primary), -2px -2px var(--shadow-secondary);
          -webkit-clip-path: var(--clip);
                  clip-path: var(--clip);
          -webkit-animation: glitch 2s infinite;
                  animation: glitch 2s infinite;
          display: none;
        }
        .cybr-btn:hover .cybr-btn__glitch {
          display: block;
        }
        .cybr-btn__glitch:before {
          content: '';
          position: absolute;
          top: calc(var(--border) * 1);
          right: calc(var(--border) * 1);
          bottom: calc(var(--border) * 1);
          left: calc(var(--border) * 1);
          -webkit-clip-path: var(--clip);
                  clip-path: var(--clip);
          background: var(--primary);
          z-index: -1;
        }
        .cybr-btn:nth-of-type(2) {
          --primary-hue: 260;
        }
        @-webkit-keyframes glitch {
          0% {
            -webkit-clip-path: var(--clip-one);
                    clip-path: var(--clip-one);
          }
          2%, 8% {
            -webkit-clip-path: var(--clip-two);
                    clip-path: var(--clip-two);
            transform: translate(calc(var(--shimmy-distance) * -1%), 0);
          }
          6% {
            -webkit-clip-path: var(--clip-two);
                    clip-path: var(--clip-two);
            transform: translate(calc(var(--shimmy-distance) * 1%), 0);
          }
          9% {
            -webkit-clip-path: var(--clip-two);
                    clip-path: var(--clip-two);
            transform: translate(0, 0);
          }
          10% {
            -webkit-clip-path: var(--clip-three);
                    clip-path: var(--clip-three);
            transform: translate(calc(var(--shimmy-distance) * 1%), 0);
          }
          13% {
            -webkit-clip-path: var(--clip-three);
                    clip-path: var(--clip-three);
            transform: translate(0, 0);
          }
          14%, 21% {
            -webkit-clip-path: var(--clip-four);
                    clip-path: var(--clip-four);
            transform: translate(calc(var(--shimmy-distance) * 1%), 0);
          }
          25% {
            -webkit-clip-path: var(--clip-five);
                    clip-path: var(--clip-five);
            transform: translate(calc(var(--shimmy-distance) * 1%), 0);
          }
          30% {
            -webkit-clip-path: var(--clip-five);
                    clip-path: var(--clip-five);
            transform: translate(calc(var(--shimmy-distance) * -1%), 0);
          }
          35%, 45% {
            -webkit-clip-path: var(--clip-six);
                    clip-path: var(--clip-six);
            transform: translate(calc(var(--shimmy-distance) * -1%));
          }
          40% {
            -webkit-clip-path: var(--clip-six);
                    clip-path: var(--clip-six);
            transform: translate(calc(var(--shimmy-distance) * 1%));
          }
          50% {
            -webkit-clip-path: var(--clip-six);
                    clip-path: var(--clip-six);
            transform: translate(0, 0);
          }
          55% {
            -webkit-clip-path: var(--clip-seven);
                    clip-path: var(--clip-seven);
            transform: translate(calc(var(--shimmy-distance) * 1%), 0);
          }
          60% {
            -webkit-clip-path: var(--clip-seven);
                    clip-path: var(--clip-seven);
            transform: translate(0, 0);
          }
          31%, 61%, 100% {
            -webkit-clip-path: var(--clip-four);
                    clip-path: var(--clip-four);
          }
        }
        @keyframes glitch {
          0% {
            -webkit-clip-path: var(--clip-one);
                    clip-path: var(--clip-one);
          }
          2%, 8% {
            -webkit-clip-path: var(--clip-two);
                    clip-path: var(--clip-two);
            transform: translate(calc(var(--shimmy-distance) * -1%), 0);
          }
          6% {
            -webkit-clip-path: var(--clip-two);
                    clip-path: var(--clip-two);
            transform: translate(calc(var(--shimmy-distance) * 1%), 0);
          }
          9% {
            -webkit-clip-path: var(--clip-two);
                    clip-path: var(--clip-two);
            transform: translate(0, 0);
          }
          10% {
            -webkit-clip-path: var(--clip-three);
                    clip-path: var(--clip-three);
            transform: translate(calc(var(--shimmy-distance) * 1%), 0);
          }
          13% {
            -webkit-clip-path: var(--clip-three);
                    clip-path: var(--clip-three);
            transform: translate(0, 0);
          }
          14%, 21% {
            -webkit-clip-path: var(--clip-four);
                    clip-path: var(--clip-four);
            transform: translate(calc(var(--shimmy-distance) * 1%), 0);
          }
          25% {
            -webkit-clip-path: var(--clip-five);
                    clip-path: var(--clip-five);
            transform: translate(calc(var(--shimmy-distance) * 1%), 0);
          }
          30% {
            -webkit-clip-path: var(--clip-five);
                    clip-path: var(--clip-five);
            transform: translate(calc(var(--shimmy-distance) * -1%), 0);
          }
          35%, 45% {
            -webkit-clip-path: var(--clip-six);
                    clip-path: var(--clip-six);
            transform: tra.........完整代码请登录后点击上方下载按钮下载查看

网友评论0