CSS动画特效

特效实现

在学习前端HTML和CSS时遇到一些好看的页面里的效果动效时总会以为是拿JS写的

CSS3特效2

css3特效1

其实我们只需要用到一点CSS3的样式就可以实现了。

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        /* background-color: #423933; */
      }
      .box {
        width: 710px;
        height: 200px;
        background-color: #423933;
        margin-top: 300px;
        margin-left: 350px;
        overflow: hidden;
      }
      .sou {
        width: 70px;
        height: 70px;
        border-radius: 50px;
        background-color: #db2f00;
        text-align: center;
        line-height: 70px;
        font-size: 25px;
        margin-top: 65px;
        color: white;
        float: left;
        animation-name: run;
        animation-duration: 2s;
        animation-iteration-count: infinite;
        animation-delay: 0.1s;
      }
      .sou2 {
        width: 70px;
        height: 70px;
        border-radius: 50px;
        background-color: #ff6d38;
        text-align: center;
        margin-top: 65px;
        line-height: 70px;
        font-size: 25px;
        color: white;
        float: left;
        margin-left: 10px;
        animation-name: run;
        animation-duration: 2s;
        animation-iteration-count: infinite;
        animation-delay: 0.2s;
      }
      .sou3 {
        width: 70px;
        height: 70px;
        border-radius: 50px;
        background-color: #ffa588;
        text-align: center;
        line-height: 70px;
        font-size: 25px;
        margin-top: 65px;
        color: white;
        float: left;
        margin-left: 10px;
        animation-name: run;
        animation-duration: 2s;
        animation-iteration-count: infinite;
        animation-delay: 0.3s;
      }
      .sou4 {
        width: 70px;
        height: 70px;
        border-radius: 50px;
        background-color: white;
        text-align: center;
        line-height: 70px;
        font-size: 25px;
        margin-top: 65px;
        color: black;
        float: left;
        margin-left: 10px;
        animation-name: run;
        animation-duration: 2s;
        animation-iteration-count: infinite;
        animation-delay: 0.4s;
      }
      .sou5 {
        width: 70px;
        height: 70px;
        border-radius: 50px;
        background-color: #98d3d3;
        text-align: center;
        line-height: 70px;
        font-size: 25px;
        margin-top: 65px;
        color: white;
        float: left;
        margin-left: 10px;
        animation-name: run;
        animation-duration: 2s;
        animation-iteration-count: infinite;
        animation-delay: 0.5s;
      }
      .sou6 {
        width: 70px;
        height: 70px;
        border-radius: 50px;
        background-color: #13a2a4;
        text-align: center;
        line-height: 70px;
        font-size: 25px;
        color: white;
        float: left;
        margin-top: 65px;
        margin-left: 10px;
        animation-name: run;
        animation-duration: 2s;
        animation-iteration-count: infinite;
        animation-delay: 0.6s;
      }
      .sou7 {
        width: 70px;
        height: 70px;
        border-radius: 50px;
        background-color: #ffa588;
        text-align: center;
        line-height: 70px;
        margin-top: 65px;
        font-size: 25px;
        color: white;
        float: left;
        margin-left: 10px;
        animation-name: run;
        animation-duration: 2s;
        animation-iteration-count: infinite;
        animation-delay: 0.7s;
      }
      .sou8 {
        width: 70px;
        height: 70px;
        border-radius: 50px;
        background-color: #ff6d38;
        text-align: center;
        line-height: 70px;
        font-size: 25px;
        color: white;
        margin-top: 65px;
        float: left;
        margin-left: 10px;
        animation-name: run;
        animation-duration: 2s;
        animation-iteration-count: infinite;
        animation-delay: 0.8s;
      }
      .sou9 {
        width: 70px;
        height: 70px;
        border-radius: 50px;
        background-color: #98d3d3;
        text-align: center;
        line-height: 70px;
        font-size: 25px;
        color: white;
        margin-top: 65px;
        float: left;
        margin-left: 10px;
        animation-name: run;
        animation-duration: 2s;
        animation-iteration-count: infinite;
        animation-delay: 0.9s;
      }
      @keyframes run {
        0% {
          transform: translateY(0px);
        }
        25% {
          transform: translateY(-20px);
        }
        50% {
          transform: translateY(200px);
        }
        50.1% {
          transform: translateY(-180px);
        }
        100% {
          transform: translateY(0px);
        }
      }
    </style>
  </head>
  <body>
    <div class="box">
      <div class="sou">s</div>
      <div class="sou2">h</div>
      <div class="sou3">u</div>
      <div class="sou4">m</div>
      <div class="sou5">e</div>
      <div class="sou6">n</div>
      <div class="sou7">g</div>
      <div class="sou8">l</div>
      <div class="sou9">i</div>
    </div>
  </body>
</html>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .box {
        width: 100%;
        height: 740px;
        position: relative;
        top: 0;
        left: 0;
      }
      .zuo {
        width: 100%;
        height: 770px;
        background: linear-gradient(to right, #f55757 50%, #eaffae 50%);
        mix-blend-mode: hue;
        border: solid 1.5px #f55757;
        line-height: 770px;
        /* font-size: 100px; */
      }
      .Zi {
        color: #fff;
        /* font-size: 120px; */
        font-weight: 600;
        mix-blend-mode: difference;
        transition: all 0.2s linear;
      }
      #tips {
        position: relative;
        width: 100%;
        line-height: 135px;
        font-size: 160px;
        height: 135px;
        background-color: rgb(0, 0, 0, 0);
        overflow: hidden;
        position: fixed;
        top: 270px;
      }
      #tips span {
        position: absolute;
        left: 0;
        margin: 0 10px;
        white-space: nowrap;
      }
      @keyframes around1 {
        from {
          left: 0;
        }
        to {
          /* left: calc(0px - var(--textWidth--) - 10px); */
          left: -100%;
        }
      }
      @keyframes around2 {
        from {
          /* left: calc(var(--textWidth--) + 10px); */
          left: 100%;
        }
        to {
          left: 0;
        }
      }
      #tips .span1 {
        animation: around1 10s linear infinite;
      }
      #tips .span2 {
        animation: around2 10s linear infinite;
      }
      .box > .Zi {
        transform: translateX(1000px);
        cursor: pointer;
      }
    </style>
  </head>
  <body>
    <div class="box">
      <div class="zuo">
        <div class="Zi" id="tips" :style="'--textWidth--:'+ msg.length+'em'">
          <span class="span1">CLASSROOO</span>
          <span class="span2">CLASSROOO</span>
        </div>
      </div>
    </div>
  </body>
</html>

这样我们就可以实现一些好看且实用的C3的特效动画了,但在我们写代码的时候有些情况还是要结合实际情况来判断和运用,从而达到事半功倍的效果。

(如果有更简介的方法,欢迎在评论区里讨论)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值