split实现按钮文字吸入方块内动画效果

代码语言:html

所属分类:表单美化

代码描述:split实现按钮文字吸入方块内动画效果

代码标签: 文字 吸入 方块 动画 效果

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


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<link type="text/css" rel="stylesheet" href="http://repo.bfw.wiki/bfwrepo/css/splitting.css">
<style>
@import url("https://fonts.googleapis.com/css?family=Lato:700&display=swap");
body,
html {
  height: 100%;
}

body {
  display: grid;
  place-items: center;
  font-family: "Lato", sans-serif;
  color: white;
  background: dodgerblue;
}

.btn--pitfall {
  --perspective: 200px;
  --rotation: 65deg;
  --duration: 200ms;
  --ease: cubic-bezier(0.33, 1, 0.68, 1);
  all: unset;
  cursor: pointer;
  position: relative;
  padding: 1rem 2rem;
  font-family: inherit;
  font-size: 1.25rem;
  border: 2px dashed transparent;
  -webkit-transition: border-color 0s;
  transition: border-color 0s;
}
.btn--pitfall::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  -webkit-transform-origin: 50% 100%;
          transform-origin: 50% 100%;
  border-radius: 0.125rem;
  -webkit-transform: perspective(var(--perspective));
          transform: perspective(var(--perspective));
  -webkit-transition: var(--duration) var(--ease);
  transition: var(--duration) var(--ease);
  pointer-events: none;
  z-index: 1;
}
.btn--pitfall::before {
  background-color: black;
  -webkit-transition-property: -webkit-transform;
  transition-property: -webkit-transform;
  transition-property: transform;
  transition-property: transform, -webkit-transform;
}
.btn--pitfall .word {
  position: relative;
  pointer-events: none;
  z-index: 2;
}

.btn--pitfall:hover {
  border-color: rgba(255, 255, 255, 0.2);
  -webkit-transition-duration: var(--duration);
          transition-duration: var(--duration);
  -webkit-transition-delay: calc(var(--duration) * 3.5);
          transition-delay: calc(var(--duration) * 3.5);
  -webkit-animation: cursor-swap calc(var(--duration) * 4) linear forwards, zoom var(--duration) linear forwards;
          animation: cursor-swap calc(var(--duration) * 4) linear forwards, zoom var(--duration) linear forwards;
}
.btn--pitfall:hover::before {
  -webkit-transform: perspective(var(--perspective));
          transform: perspective(var(--perspective));
  -webkit-animation: pit calc(var(--duration) * 4) var(--ease) forwards;
          animation: pit calc(var(--duration) * 4) var(--ease) forwards;
}
.btn--pitfall:hover .char {
  -webkit-animation: fall calc(var(--duration) * 2) linear forwards;
          animation: fall calc(var(--duration) * 2) linear forwards;
  -webkit-animation-delay: calc(var(--distance-sine) * 0.04s);
          animation-delay: calc(var(--distance-sine) * 0.04s);
}

@-webkit-keyframes zoom {
  60% {
    -webkit-transform: scale(1.2);
            transform: scale(1.2);
  }
}

@keyframes zoom {
  60% {
    -webkit-transform: scale(1.2);
            transform: scale(1.2);
  }
}
@-webkit-keyframes cursor-swap {
  0%,
  80% {
    cursor: -webkit-grab;
    cursor: grab;
  }
  100% {
    cursor: help;
  }
}
@keyframes cursor-swap {
  0%,
  80% {
    cursor: -webkit-grab;
    cursor: grab;
  }
  100% {
    cursor: help;
  }
}
@-webkit-keyframes fall {
  20% {
    -webkit-transform: scale(calc(1 * var(--distance-percent) + 1.5)) rotate(calc(15deg * var(--distance-sine))) translateY(-20%);
            transform: scale(calc(1 * var(--distance-percent) + 1.5)) rotate(calc(15deg * var(--distance-sine))) translateY(-20%);
  }
  40% {
    -webkit-transform: scale(calc(1 * var(--distance-percent) + 1.2)) rotate(calc(25deg * var(--distance-sine.........完整代码请登录后点击上方下载按钮下载查看

网友评论0