美文网首页
css animation @keyframes 动画

css animation @keyframes 动画

作者: TDX田冬雪 | 来源:发表于2021-01-14 19:04 被阅读0次

    需求:语音播放动态效果

    方案:使用如下图片,利用 css animation @keyframes  做动画

    html

    <span class="horn" :class="{'active': scope.row.isPlay}"></span> 

    <audio :id="'audio_'+scope.row.commentId" ref="audio" :src="scope.row.voiceUrl"></audio>

    css

    .horn{

      width: 25px;

      height: 20px;

      background-image: url('../../../assets/images/voice/icon.png');

      background-size: 100% 100%;

      position: absolute;

      left: 10px;

      top: 50%;

      // margin-top: 50%;

      transform: translateY(-49%);

    }

    .horn.active{

      animation: fadeInOut 1s infinite;

    }

    @keyframes fadeInOut {

      0% {

        background-image: url('./assets/images/voice/1.png');

      }

      70% {

        background-image: url('./assets/images/voice/2.png');

      }

      90% {

        background-image: url('./../assets/images/voice/icon.png');

      }

    }

    相关文章

      网友评论

          本文标题:css animation @keyframes 动画

          本文链接:https://www.haomeiwen.com/subject/urtbaktx.html