标题字延迟动画效果

 

html

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

<head>
  <meta charset="UTF-8">
  <title>CodePen - Animated Highlight</title>
  <link rel="stylesheet" href="./style.css">

</head>

<body>
  <div id="container">
    <h1>
      <span><i style="--i:0">The</i></span>
      <span><i style="--i:1">best</i></span>
      <span><i style="--i:2">products</i></span>
      <span><i style="--i:3">start</i></span>
      <span><i style="--i:4">with</i></span>
      <span><i style="--i:5">Sketch</i></span>
    </h1>
    <p>
      Create, prototype, collaborate, and bring your ideas to life with the design platform used by over one million
      people — from freelancers, to the world’s largest teams.
    </p>
  </div>
</body>

</html>

css

:root {
  font-size: 32px;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  min-height: 100vh;
  font-family: Helvetica;
}

#container {
  width: 600px;
}

h1 {
  margin: 0;
  letter-spacing: -2px;
}


span {
  display: inline-block;
  overflow: hidden;
  position: relative;
  top: .8rem;
  animation: .3s swift-up ease-in-out forwards calc(var(--i) * 0.1s);
}

i {
  font-style: normal;
  position: relative;
  top: 2rem;
  animation: .5s swift-up ease-in-out forwards calc(var(--i) * 0.1s);
}

@keyframes swift-up {
  to {
    top: 0rem;
  }
}


p {
  font-size: .9rem;
  color: #666;
  line-height: 1.3rem;
  position: relative;
  top: .8rem;
  opacity: 0;
  animation: .5s swift-up ease-out forwards, .5s fade-in ease-out forwards;
  animation-delay: .8s;
}

@keyframes fade-in {
  to {
    opacity: 1;
  }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值