a标签active不起效果_CSS3仿网易云音乐听歌识曲动态效果

该博客介绍了如何利用CSS3的动画属性和transition标签实现淡入淡出效果,来创建类似网易云音乐听歌识曲的水波纹动态效果。通过控制元素的opacity值和box-shadow大小,结合关键帧动画@keyframes,营造出从中心向外扩散的视觉效果。
摘要由CSDN通过智能技术生成

利用CSS3动画属性,以及transition 标签控制样式opacity值实现淡入淡出效果,从而实现类似水波纹的动态效果。

具体实现效果如图:

b73ca534802913be55a7c6cb5f4253dd.png

demo代码如下:

DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport"

        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

    <title>录音效果title>

    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js">script>

head>

<style>

    body{

        background-color: #333333;

        text-align: center;

    }

    .content{

        height:10px;

        width:100px;

        border-radius:100%;

        position: relative;

        margin:200px auto;

    }

    .fade-enter {

        opacity: 0;

    }

    .fade-enter-active {

        transition: opacity 1s;

    }

    .fade-leave-to {

        opacity: 0;

    }

    .fade-leave-active {

        transition: opacity 3s;

    }

    .dot {

        animation: sploosh 1.5s cubic-bezier(0.165, 0.84, 0.44, 1);

    }

    .dot2 {

        animation: sploosh2 1.5s cubic-bezier(0.165, 0.84, 0.44, 1);

    }

    .dot3 {

        animation: sploosh3 1.5s cubic-bezier(0.165, 0.84, 0.44, 1);

    }

    .dot,

    .dot2,

    .dot3 {

        height: 100px;

        width: 100px;

        font-size: 20px;

        color: #fff;

        line-height: 100px;

        text-align: center;

        border-radius: 100%;

        position: absolute;

        z-index: 20;

        animation-iteration-count: infinite;

        background: transparent;

    }

    .dot-start {

        height: 100px;

        width: 100px;

        font-size: 20px;

        color: #fff;

        line-height: 100px;

        text-align: center;

        border-radius: 100%;

        position: absolute;

        z-index: 10;

        animation-iteration-count: infinite;

        background: transparent;

        background-color: rgba(255, 220, 1, 0.7);

    }

    .dot30 {

        height: 100px;

        width: 100px;

        font-size: 20px;

        color: #fff;

        line-height: 100px;

        text-align: center;

        border-radius: 100%;

        position: absolute;

        z-index: 30;

        animation-iteration-count: infinite;

        background: transparent;

        background-color: rgba(255, 220, 1, 0.7);

    }

    @keyframes sploosh {

        0% {

            box-shadow: 0 0 0 0px rgba(255, 220, 1, 0.7);

            background: rgba(255, 220, 1, 0.7);

        }

        100% {

            box-shadow: 0 0 0 30px rgba(255, 220, 1, 0);

            background: rgba(255, 220, 1, 0);

        }

    }

    @keyframes sploosh2 {

        0% {

            box-shadow: 0 0 0 0px rgba(255, 220, 1, 0.7);

            background: rgba(255, 220, 1, 0.7);

        }

        100% {

            box-shadow: 0 0 0 20px rgba(255, 220, 1, 0);

            background: rgba(255, 220, 1, 0.3);

        }

    }

    @keyframes sploosh3 {

        0% {

            box-shadow: 0 0 0 0px rgba(255, 220, 1, 0.7);

            background: rgba(255, 220, 1, 0.7);

        }

        100% {

            box-shadow: 0 0 0 10px rgba(255, 220, 1, 0);

            background: rgba(255, 220, 1, 1);

        }

    }

style>

<body>

    <div id="app">

        <div class="content">

            <transition name="fade">

                <div v-if="show">

                    <div v-if="show" class="dot">

                        <div class="dot2">

                            <div id="div3" class="dot3">div>

                        div>

                    div>

                div>

            transition>

            <div v-if="show" class="dot30">

                正在录音

            div>

            <div class="dot-start">

            div>

        div>

        <button v-if="show" @click="startRecord">停止录音button>

        <button v-if="!show" @click="endRecord">开始录音button>

    div>

    <script>

        new Vue({

            el: '#app',

            data() {

                return {

                    show: false,

                    show1: false

                };

            },

            methods: {

                startRecord(){

                   this.show=false;

                   this.show1=true;

                },

                endRecord(){

                   this.show=true;

                   this.show1=false;

                }

            }

        })

    script>

body>

html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值