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 天前
Lambda 表达式、方法引用(Method Reference)语法
java·前端·servlet
石小石Orz1 天前
油猴脚本实现生产环境加载本地qiankun子应用
前端·架构
从前慢丶1 天前
前端交互规范(Web 端)
前端
像我这样帅的人丶你还1 天前
别再让JS耽误你进步了。
css·vue.js
CHU7290351 天前
便捷约玩,沉浸推理:线上剧本杀APP功能版块设计详解
前端·小程序
GISer_Jing1 天前
Page-agent MCP结构
前端·人工智能
王霸天1 天前
💥别再抄网上的Scale缩放代码了!50行源码教你写一个永不翻车的大屏适配
前端·vue.js·数据可视化
小领航1 天前
用 Three.js + Vue 3 打造炫酷的 3D 行政地图可视化组件
前端·github
@大迁世界1 天前
2026年React大洗牌:React Hooks 将迎来重大升级
前端·javascript·react.js·前端框架·ecmascript
PieroPc1 天前
一个功能强大的 Web 端标签设计和打印工具,支持服务器端直接打印到局域网打印机。Fastapi + html
前端·html·fastapi