splitting实现多种文字字母跳动动画效果代码

代码语言:html

所属分类:动画

代码描述:splitting实现多种文字字母跳动动画效果代码

代码标签: splitting 多种 文字 字母 跳动 动画

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

<!DOCTYPE html>
<html lang="en" >

<head>
 
<meta charset="UTF-8">
 

 
 
 
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/splitting.css">
 
<style>

@import url("https://fonts.googleapis.com/css2?family=Noto+Sans&display=swap");
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
}

.container {
  max-height: 100vh;
  overflow-y: scroll;
  position: relative;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
}

.headline {
  align-items: center;
  background-color: var(--color);
  display: flex;
  font-family: "Noto Sans", sans-serif;
  font-weight: 700;
  font-size: 6rem;
  height: 100vh;
  justify-content: center;
  overflow: hidden;
  perspective: 1000px;
  scroll-snap-align: start;
}
.headline:nth-child(1) {
  --color: #3399dd;
}
.headline:nth-child(2) {
  --color: #ff8888;
}
.headline:nth-child(3) {
  --color: #11bb99;
}
.headline:nth-child(4) {
  --color: #ff22cc;
}
.headline:nth-child(5) {
  --color: #ee7733;
}
.headline:nth-child(6) {
  --color: #ffcc99;
}
.headline:nth-child(7) {
  --color: #99dd33;
}

.word, .char {
  animation-delay: var(--del);
  animation-direction: var(--dir, normal);
  animation-duration: var(--dur);
  animation-iteration-count: var(--it, infinite);
  animation-name: var(--name);
  animation-timing-function: var(--tf);
  animation-fill-mode: var(--fill, forwards);
  display: inline-block;
  position: relative;
  transform-origin: 50% 100%;
  z-index: 1;
}

#controls {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  display: flex;
  align-items: center;
}

.btn {
  background-color: rgba(0, 0, 0, 0.4);
  border: none;
  color: rgba(255, 255, 255, 0.4);
  padding: 10px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 2px 2px;
  cursor: pointer;
  border-radius: 5px;
  transition: background-color 0.3s;
}

.btn:hover {
  background-color: rgba(0, 0, 0, 0.2);
  color: black;
}

#fullscreenBtn {
  font-size: 20px;
}

#upCaretBtn, #downCaretBtn {
  position: fixed;
  bottom: 90px;
  right: 40px;
  background-color: #333333;
  color: white;
  border: none;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 1000;
  transition: transform 0.2s, background-color 0.3s;
}

#upCaretBtn:hover, #downCaretBtn:hover {
  background-color: #2877b0;
  transform: scale(1.1);
  font-size: 2rem;
}

#downCaretBtn {
  bottom: 20px;
}

.textBounce .char {
  animation-iteration-count: infinite;
  animation-direction: alternate;
  --name: bounce;
  --dur: 500ms;
  --del: calc(var(--char-index) * -0.8s);
  --tf: ease;
}
.textBounce .char:nth-child(2n) {
  --name: bounce-next;
}
@keyframes bounce {
  0% {
    top: 60px;
    height: 5px;
    border-radius: 60px 60px 20px 20px;
    transform: scaleX(2);
  }
  25% {
    height: 30px;
    border-radius: 50%;
    transform: scaleX(1);
  }
  100% {
    top: 0;
  }
}
@keyframes bounce-next {
  0% {
    top: 60px;
    height: 5px;
    border-radius: 60px 60px 20px 20px;
    transform: rotateY(0.5turn) scaleX(2);
  }
  25% {
    height: 30px;
    border-radius: 50%;
    transform: rotateY(0.25turn) scaleX(1);
  }
  100% {
    top: 0;
  }
}

.textFlip .char {
  transform-origin: center;
  --name: flip;
  --dur: 4000ms;
  --del: calc(var(--char-index) * 0.075s);
  --tf: linear;
}.........完整代码请登录后点击上方下载按钮下载查看

网友评论0