svg+js实现订阅按钮点击交互动画效果代码

代码语言:html

所属分类:动画

代码描述:svg+js实现订阅按钮点击交互动画效果代码

代码标签: svg js 订阅 按钮 点击 交互 动画

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

<html>

<head>
    <style>
        .unsub-button {
          background: none;
          border: 0;
          color: #222;
          display: block;
          font-family: "Quicksand", sans-serif;
          font-size: 13px;
          font-weight: 600;
          height: 40px;
          outline: none;
          padding-right: 32px;
          position: relative;
          width: 160px;
          -webkit-tap-highlight-color: transparent;
        }
        .unsub-button.ready {
          cursor: pointer;
        }
        .unsub-button.clicked::before {
          box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
          height: 32px;
          width: 128px;
        }
        .unsub-button.clicked .unsub-button__icon {
          opacity: 0;
          transform: translate(-150%, -50%) scale(0);
        }
        .unsub-button.clicked .unsub-button__default-text {
          opacity: 0;
          transform: translate(10%, 0%) scale(0);
        }
        .unsub-button.clicked .unsub-button__confirm-text .word {
          opacity: 1;
          top: 0;
        }
        .unsub-button.clicked .unsub-button__confirm-text .char {
          animation-name: bounce;
        }
        .unsub-button.show-instructions .unsub-button__confirm-text {
          opacity: 0;
        }
        .unsub-button.show-instructions .unsub-button__instruction-text {
          opacity: 1;
          top: 110%;
        }
        .unsub-button.show-instructions .unsub-button__kid {
          pointer-events: auto;
        }
        .unsub-button.show-instructions .unsub-button__kid-wrapper {
          transform: translate(0px, 20px) rotate(0);
        }
        .unsub-button.show-instructions .target {
          cursor: pointer;
        }
        .unsub-button.show-instructions.happy .happy {
          opacity: 1;
        }
        .unsub-button.show-instructions.worried .worried {
          opacity: 1;
        }
        .unsub-button.show-instructions.sad::after {
          color: #222;
          opacity: 1;
          transition: opacity 600ms linear 400ms, color 400ms linear 1400ms;
        }
        .unsub-button.show-instructions.sad .sad {
          opacity: 1;
        }
        .unsub-button::before {
          background-color: #fff;
          border-radius: 5px;
          box-shadow: 0 3px 3px rgba(0, 0, 0, 0.05);
          content: "";
          display: block;
          height: 100%;
          left: 50%;
          position: absolute;
          top: 50%;
          transform: translate(-50%, -50%);
          transition: width 300ms ease-in-out, height 300ms ease-in-out, box-shadow 300ms linear;
          width: 100%;
          z-index: 1;
        }
        .unsub-button::after {
          align-items: center;
          background: #fff;
          color: #fff;
          content: "How could you...";
          display: flex;
          height: 100vh;
          justify-content: center;
          left: 50%;
          min-width: 300px;
          opacity: 0;
          pointer-events: none;
          position: absolute;
          top: 50%;
          transform: translate(-50%, -50%);
          transition: opacity 600ms linear 2000ms, color 600ms linear 1400ms;
          width: 33.34vw;
          z-index: 10;
        }
        .unsub-button__default-text {
          display: block;
          opacity: 1;
          position: relative;
          transform: none;
          transition: opacity 200ms linear, transform 200ms ease;
          z-index: 3;
        }
        .unsub-button__icon {
          fill: none;
          stroke: #222;
          stroke-linecap: round;
          stroke-linejoin: round;
          stroke-width: 5;
          opacity: 1;
          position: absolute;
          right: 20px;
          top: 50%;
          transform: translate(0, -50%);
          transition: opacity 200ms linear, transform 200ms ease;
          width: 24px;
          z-index: 2;
        }
        .unsub-button__icon .cancel-color {
          stroke: #ff6161;
        }
        .unsub-button__confirm-text {
          left: 50%;
          opacity: 1;
          position: absolute;
          top: 50%;
          transform: translate(-50%, -50%);
          transition: opacity 200ms linear;
          white-space: nowrap;
          z-index: 3;
        }
        .unsub-button__confirm-text .word {
          margin-right: 5px;
          opacity: 0;
          position: relative;
          top: -5px;
          transition: opacity 400ms linear var(--word-delay), top 400ms linear var(--word-delay);
        }
        .unsub-button__confirm-text .word--bold {
          color: #ff6161;
          margin: 0;
          transition: opacity 400ms linear var(--word-delay);
          white-space: nowrap;
        }
        .unsub-button__confirm-text .word .char {
          --bounceHeight: -5px;
          animation-duration: 400ms;
          animation-direction: alternate;
          animation-delay: var(--char-delay);
          animation-iteration-count: 2;
          display: inline-block;
        }
        .unsub-button__instruction-text {
          color: #fff;
          left: 50%;
          opacity: 0;
          pointer-events: none;
          position: absolute;
          top: 100%;
          transform: translate(-50%, 0%);
          transition: top 500ms ease 700ms, opacity 300ms linear 700ms;
          white-space: nowrap;
          z-index: 3;
        }
        .unsub-button__kid {
          bottom: 4px;
          left: 50%;
          pointer-events: none;
          position: absolute;
          transform: translate(-50%, 0%);
          width: 150px;
          z-index: 5;
        }
  .........完整代码请登录后点击上方下载按钮下载查看

网友评论0