1、波浪文本動(dòng)畫特效

效果圖:


blwb.gif

index.html

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

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>波浪文本動(dòng)畫特效</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      font-family: '微軟雅黑';
    }
    .blwb {
      margin: 100px auto;
      width:30%;
      min-height: 200px;
      background: #000;
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
    }
    .blwb span {
      position: relative;
      color: #fff;
      font-size: 18px;
      animation: animate 1s ease-in-out infinite;
      animation-delay: calc(.1s*var(--i));
    }

    @keyframes animate {
      0% {
        transform: translateY(0px);
      }

      20% {
        transform: translateY(-24px);
      }
      
      40%,
      100% {
        transform: translateY(0);
      }
    }
  </style>
</head>

<body>
  <div class="blwb">
    <span style="--i:1">內(nèi)</span>
    <span style="--i:2">容</span>
    <span style="--i:3">加</span>
    <span style="--i:4">載</span>
    <span style="--i:5">中</span>
    <span style="--i:6">.</span>
    <span style="--i:7">.</span>
    <span style="--i:8">.</span>
  </div>
</body>

</html>

知識(shí)點(diǎn):
animation屬性是一個(gè)簡(jiǎn)寫屬性,用于設(shè)置六個(gè)動(dòng)畫屬性
語(yǔ)法:
animation:name|動(dòng)畫名稱 duration|完成動(dòng)畫所需時(shí)間 timing-function|速度曲線 delay|開始前延遲時(shí)間 iteration-count|播放次數(shù) direction|是否反向播放;

1、animation-name:@keyframe動(dòng)畫規(guī)定的名稱;(必須)
2、animation-duration:完成動(dòng)畫所花費(fèi)的時(shí)間,以秒或者毫秒計(jì);(必須,否則不會(huì)播放動(dòng)畫,默認(rèn)是0,表示無(wú)動(dòng)畫)
3、animation-timing-function:規(guī)定動(dòng)畫的速度曲線;(默認(rèn)ease)
  linear:勻速播放動(dòng)畫;
  ease:默認(rèn),低速開始,然后加快,在結(jié)束前再變慢(慢-快-慢);
  ease-in:低速開始;
  ease-out:低速結(jié)束;
  ease-in-out:以低速開始和結(jié)束;
  cubic-bezier(n,n,n,n):在 cubic-bezier 函數(shù)中設(shè)置自己的值??赡艿闹凳菑?0 到 1 的數(shù)值。
4、animation-delay:規(guī)定在動(dòng)畫開始之前的延遲,默認(rèn)值是0,表示不延遲,立即播放動(dòng)畫。單位是s或者ms毫秒。允許設(shè)置負(fù)時(shí)間,意思是讓動(dòng)畫動(dòng)作從該時(shí)間點(diǎn)開始啟動(dòng),之前的動(dòng)畫不顯示;例如-2s使動(dòng)畫馬上開始,但前2秒的動(dòng)畫被跳過;
5、animation-iteration-count:規(guī)定動(dòng)畫應(yīng)該播放的次數(shù);默認(rèn)值為1,播放完一遍后不循環(huán)播放。(n:播放次數(shù)數(shù)值;infinite:無(wú)限次播放)
6、animation-direction:規(guī)定是否應(yīng)該輪流反向播放動(dòng)畫;(normal:默認(rèn)值,正常播放;alternate:輪流反向播放|奇數(shù)次正向播放,偶數(shù)次反向播放,alternate-reverse:輪流反向播放|奇數(shù)次反向播放動(dòng)畫,偶數(shù)次正向播放動(dòng)畫,和alternate正好相反。)

animation-fill-mode:設(shè)置動(dòng)畫結(jié)束時(shí),盒子的狀態(tài)。屬性值:forwards:保持動(dòng)畫結(jié)束后的狀態(tài)(默認(rèn));backwards:動(dòng)畫結(jié)束后回到最初的狀態(tài);

通過 @keyframes 規(guī)則,您能夠創(chuàng)建動(dòng)畫
語(yǔ)法:
@keyframes animationname {keyframes-selector {css-styles;}}
animationname---必需。定義動(dòng)畫的名稱。
keyframes-selector---必需。動(dòng)畫時(shí)長(zhǎng)的百分比。
    合法的值:
    0-100%
    from(與 0% 相同)
    to(與 100% 相同)
css-styles----必需。一個(gè)或多個(gè)合法的 CSS 樣式屬性。
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容