CSS实现波浪效果图

波浪效果图
在这里插入图片描述

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

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  * {
    margin: 0;
    padding: 0;
  }
  [v-cloak]{
    display: none;
  }

  .zjdh {
    width: 200px;
    height: 200px;
  }

  .level {
    position: relative;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    width: 12.5rem;
    height: 12.5rem;
    border-radius: 50%;
    background-color: #23d7c8;
    overflow: hidden;
    border: .106667rem solid #c6ffed;
    z-index: 100;
  }

  .level:before,
  .level:after {
    content: "";
    position: absolute;
    left: 50%;
    min-width: 300vw;
    min-height: 300vw;
    background-color: #097b9d;
    -webkit-animation-name: rotate;
    animation-name: rotate;
    -webkit-animation-iteration-count: infinite;
    animation-iteration-count: infinite;
    -webkit-animation-timing-function: linear;
    animation-timing-function: linear;
  }

  .level:before {
    bottom: 50%;
    border-radius: 45%;
    -webkit-animation-duration: 10s;
    animation-duration: 10s;
  }

  .level:after {
    bottom: 0%;
    opacity: 0;
    border-radius: 47%;
    -webkit-animation-duration: 10s;
    animation-duration: 10s;
  }

  @-webkit-keyframes rotate {
    0% {
      -webkit-transform: translate(-50%, 0) rotateZ(0deg);
      transform: translate(-50%, 0) rotateZ(0deg);
    }

    50% {
      -webkit-transform: translate(-50%, -1%) rotateZ(180deg);
      transform: translate(-50%, -1%) rotateZ(180deg);
    }

    100% {
      -webkit-transform: translate(-50%, 0%) rotateZ(360deg);
      transform: translate(-50%, 0%) rotateZ(360deg);
    }
  }

  @keyframes rotate {
    0% {
      -webkit-transform: translate(-50%, 0) rotateZ(0deg);
      transform: translate(-50%, 0) rotateZ(0deg);
    }

    50% {
      -webkit-transform: translate(-50%, -1%) rotateZ(180deg);
      transform: translate(-50%, -1%) rotateZ(180deg);
    }

    100% {
      -webkit-transform: translate(-50%, 0%) rotateZ(360deg);
      transform: translate(-50%, 0%) rotateZ(360deg);
    }
  }

  .jd {
    z-index: 50;
    left: 50%;
    -webkit-transform: translate(0%);
    transform: translate(0%);
    width: 100%;
    text-align: center;
    font-size: 1.9375rem;
    margin-top: 3.375rem;
    color: #fff;
  }
</style>

<body>
  <div id='app' v-cloak>
    <div class="zjdh">
      <div class="level">
        <div class="jd">50%</div>
      </div>
    </div>
  </div>
</body>
<script src="https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6/dist/vue.min.js"></script>
<script>
  var Vue = new Vue({
    el: '#app',
    data: {

    },
    created() {
      let that = this
    },
    methods: {

    }
  })
</script>

</html>

主要代码

.level:before {
    bottom: 50%; //波浪占整个圆球的高度
    border-radius: 45%;
    -webkit-animation-duration: 10s;
    animation-duration: 10s;
  }

  .level:after {
    bottom: 0%; 
    opacity: 0;
    border-radius: 47%;
    -webkit-animation-duration: 10s;
    animation-duration: 10s;
  }
  
@keyframes rotate {
    0% {
      -webkit-transform: translate(-50%, 0) rotateZ(0deg);
      transform: translate(-50%, 0) rotateZ(0deg);
    }

    50% {
      -webkit-transform: translate(-50%, -1%) rotateZ(180deg);  //-50%:波浪水平上下波动
      transform: translate(-50%, -1%) rotateZ(180deg);               //-1%:上下波动1%,值越小上下波动的幅度就越大
    }

    100% {
      -webkit-transform: translate(-50%, 0%) rotateZ(360deg);
      transform: translate(-50%, 0%) rotateZ(360deg);
    }
  }

波浪的高度是动态的话

let data=50%
$('head').append('<style>.level:before{bottom:' + data + '!important;}</style>');
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值