CSS效果之电影字幕特效

代码来自 https://github.com/Aaronliu2016/css-tricks


<!-- run -->
<style>
.bg{
background-color: #111;
  background: radial-gradient(#333, #111);
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: #fff;
  text-align: center;
  width: 95vw;
  font-weight: 700;
  overflow: hidden;
}

.fly-title {
  font-size: 4em;
  margin: 40vh auto;
  height: 20vh;
}

.fly-title div {
  position: fixed;
  margin: 2vh 0;
  left: 10vw;
  width: 80vw;
  opacity: 0;
  animation: switch 32s linear infinite;
}

.fly-title span {
  display: block;
  font-size: 0.4em;
  opacity: 0.8;
}

.fly-title div:nth-child(2) {
  animation-delay: 4s;
}

.fly-title div:nth-child(3) {
  animation-delay: 8s;
}

.fly-title div:nth-child(4) {
  animation-delay: 12s;
}

.fly-title div:nth-child(5) {
  animation-delay: 16s;
}

.fly-title div:nth-child(6) {
  animation-delay: 20s;
}

.fly-title div:nth-child(7) {
  animation-delay: 24s;
}

.fly-title div:nth-child(8) {
  animation-delay: 28s;
}


@keyframes switch {
  0% {
    opacity: 0;
    filter: blur(20px);
    transform: scale(12);
  }

  3% {
    opacity: 1;
    filter: blur(0);
    transform: scale(1);
  }

  10% {
    opacity: 1;
    filter: blur(0);
    transform: scale(0.9);
  }

  13% {
    opacity: 0;
    filter: blur(10px);
    transform: scale(.1);
  }

  80% {
    opacity: 0;
  }

  100% {
    opacity: 0;
  }
}

</style>

<div class="bg">
<div class="fly-title">
    <div><span>CSS+HTML</span>每日练手</div>
    <div>电影级<span>字幕特效</span></div>
    <div>只需几行CSS<span>即可轻松实现</span></div>
    <div><span>是的,你没看错</span>只有CSS+HTML</div>
    <!-- 这里为了方便循环,重复一次 -->
    <div><span>CSS+HTML</span>每日练手</div>
    <div>电影级<span>字幕特效</span></div>
    <div>只需几行CSS<span>即可轻松实现</span></div>
    <div><span>是的,你没看错</span>只有CSS+HTML</div>
  </div>
</div>

posted @ 2022-11-02 20:14  CoderWGB  阅读(129)  评论(0)    收藏  举报