CSS实现动态水滴效果

今天在B站上,看到了一个使用HTML和CSS,实现动态水滴的效果https://www.bilibili.com/video/BV1Qy4y1L7ot,感觉挺好玩的,就试了式。

<!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>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            background: #1e90ff;
        }

        .main {
            height: 400px;
            width: 400px;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            box-sizing: border-box;
            background: transparent;
            border-radius: 42% 58% 61% 39% / 32% 32% 68% 68%  ;
            box-shadow: inset 10px 20px 30px rgba(0, 0, 0, .5),
                10px 10px 20px rgba(0, 0, 0, .3),
                15px 15px 30px rgba(0, 0, 0, .3),
                inset -10px -10px 15px rgba(255, 255, 255, .7);
            animation: move 8s linear infinite;
        }
        /* 使用伪类添加两个高亮 */
        .main::after{
            content: '';
            width: 40px;
            height: 40px;
            background: rgba(255, 255, 255, .8);
            border-radius: 50%;
            position: absolute;
            top:80px;
            left: 60px;
        }
        .main::before{
            content: '';
            width: 20px;
            height: 20px;
            background: rgba(255, 255, 255, .8);
            border-radius: 50%;
            position: absolute;
            top:60px;
            left: 110px;
        }
        /* 使用动画,让水滴动起来*/
        @keyframes move {
            25%{
                border-radius:42% 58% 43% 57% / 32% 34% 66% 68% ;
            }
            50%{
                border-radius: 42% 58% 51% 49% / 32% 27% 73% 68% ;
            }
            75%{
                border-radius: 42% 58% 62% 38% / 32% 37% 63% 68% ;
            }

        }
    </style>
</head>

<body>
    <div class="main"></div>
</body>

</html>

效果如下:

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值