taro(react、vue) css 波纹动画

这篇博客介绍了如何利用CSS的绝对定位、相对定位以及关键帧动画(@keyframes)来创建一个圆形波动动画效果。示例中展示了Taro和浏览器版本的代码实现,通过调整元素的透明度和缩放来实现动画的视觉效果。适用于前端开发者学习CSS动画技巧。
摘要由CSDN通过智能技术生成

前言

想弄一个波动效果的动画~,其实主要涉及到css知识点。要学会用绝对定位、相对定位

实现效果

 

taro版

css


.recycle_device_image {
    position: relative;
    width: 630rpx;
    height: 600rpx;
    /* padding: 40rpx 0; */
    text-align: center;
    margin: 0 auto;
    border-radius: 50%;

    background-image: url('../../../resource/my/recycle/1.png');
    background-size: 60% 60%;
    background-repeat: no-repeat;
    background-position: center center;

     background-color: #188ffe;
}


.circle {
    position: absolute;
    width: calc(100% - 20rpx); /* 减去边框的大小 */
    height: calc(100% - 20rpx);/* 减去边框的大小 */
    border-radius: 50%;
    opacity: 0;
    border: 10rpx solid #87c5fe;
}

.circle:first-child {
    animation: circle-opacity 2s infinite;
    animation-delay: .3s;
}

.circle:nth-child(2) {
    animation: circle-opacity 2s infinite;
    animation-delay: .8s;
}


@keyframes circle-opacity{
    from {
        opacity: 1;
        transform: scale(.6);
    }
    to {
        opacity: 0;
        transform: scale(1);
    }
}

jsx

<View style="margin-top: 20rpx;">

  <View className="recycle_device_image">
    <View className="circle"></View>
    <View className="circle"></View>
  </View>

  <View className="recycle_device_title">
    <Text>连接设备</Text>
  </View>

</View>

浏览器版

css

.container {
    margin: 40rpx;
}

.dot {
    position: relative;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background-color: #33ccff;
    z-index: 2;
}

.circle {
    position: absolute;
    width: calc(100% - 6px); /* 减去边框的大小 */
    height: calc(100% - 6px);/* 减去边框的大小 */
    border-radius: 50%;
    opacity: 0;
    border: 3px solid red;
}

.circle:first-child {
    animation: circle-opacity 2s infinite;
    animation-delay: .3s;
}

.circle:nth-child(2) {
    animation: circle-opacity 2s infinite;
    animation-delay: .6s;
}

/* 
.circle:nth-child(3) {
     animation: circle-opacity 2s infinite;
    animation-delay: .6s;
} */

@keyframes circle-opacity{
    from {
        opacity: 1;
        transform: scale(0);
    }
    to {
        opacity: 0;
        transform: scale(1);
    }
}

html

<View className='container'>
  <View className="dot">
    <View className="circle"></View>
    <View className="circle"></View>
    <View className="circle"></View>
  </View>
</View>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

An_s

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值