CSS实现水滴样式

html 复制代码
<!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>
  <body>
    <div class="water-drop-animated"></div>

    <style>
      body {
        background-color: #f0f2f5;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        margin: 0;
      }

      .water-drop-animated {
        width: 200px;
        height: 200px;
        background-color: #f0f2f5;

        /* 初始形状稍微不规则一点 */
        border-radius: 50%;

        /* 保持之前的拟态阴影 */
        box-shadow: 20px 20px 60px #d1d9e6, -20px -20px 60px #ffffff,
          inset 10px 10px 20px rgba(0, 0, 0, 0.05),
          inset -10px -10px 20px rgba(255, 255, 255, 0.5);

        /* 绑定动画:持续 4 秒,无限循环,平滑过渡 */
        animation: liquid 4s ease-in-out infinite;
        position: relative;
      }

      /* 模拟顶部高光点,让它随水滴一起动 */
      .water-drop-animated::after {
        content: "";
        position: absolute;
        top: 25%;
        left: 25%;
        width: 25px;
        height: 15px;
        background: rgba(255, 255, 255, 0.6);
        border-radius: 50%;
        filter: blur(2px);
        transform: rotate(-45deg);
      }

      /* 定义形状变化的动画 */
      @keyframes liquid {
        0%,
        100% {
          border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%;
          transform: translate(0, 0) rotate(0deg);
        }
        33% {
          /* 变成稍微扁圆的状态 */
          border-radius: 60% 40% 55% 45% / 45% 55% 45% 55%;
          transform: translate(5px, -5px) rotate(2deg);
        }
        66% {
          /* 变成稍微拉长的状态 */
          border-radius: 45% 55% 40% 60% / 55% 45% 60% 40%;
          transform: translate(-5px, 5px) rotate(-2deg);
        }
      }
    </style>
  </body>
</html>
相关推荐
梦帮科技1 小时前
Node.js配置生成器CLI工具开发实战
前端·人工智能·windows·前端框架·node.js·json
VT.馒头1 小时前
【力扣】2695. 包装数组
前端·javascript·算法·leetcode·职场和发展·typescript
css趣多多2 小时前
一个UI内置组件el-scrollbar
前端·javascript·vue.js
C澒2 小时前
前端整洁架构(Clean Architecture)实战解析:从理论到 Todo 项目落地
前端·架构·系统架构·前端框架
C澒2 小时前
Remesh 框架详解:基于 CQRS 的前端领域驱动设计方案
前端·架构·前端框架·状态模式
Charlie_lll2 小时前
学习Three.js–雪花
前端·three.js
onebyte8bits2 小时前
前端国际化(i18n)体系设计与工程化落地
前端·国际化·i18n·工程化
C澒3 小时前
前端分层架构实战:DDD 与 Clean Architecture 在大型业务系统中的落地路径与项目实践
前端·架构·系统架构·前端框架
BestSongC3 小时前
行人摔倒检测系统 - 前端文档(1)
前端·人工智能·目标检测
0思必得03 小时前
[Web自动化] Selenium处理滚动条
前端·爬虫·python·selenium·自动化