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>
相关推荐
不爱说话郭德纲7 小时前
告别漫长的HbuilderX云打包排队!uni-app x 安卓本地打包保姆级教程(附白屏、包体积过大排坑指南)
android·前端·uni-app
唐叔在学习7 小时前
[前端特效] 左滑显示按钮的实现介绍
前端·javascript
用户5282290301807 小时前
【学习笔记】ECMAScript 词法环境全解析
前端
青青家的小灰灰7 小时前
React 架构进阶:自定义 Hooks 的高级设计模式与最佳实践
前端·react.js·前端框架
Angelial7 小时前
Vite 性能瓶颈排查标准流程
前端
不要秃头啊7 小时前
别再谈提效了:AI 时代的开发范式本质变了
前端·后端·程序员
青青家的小灰灰7 小时前
深入理解事件循环:异步编程的基石
前端·javascript·面试
用泥种荷花8 小时前
【LangChain.js学习】 向量数据库(内存/持久化)
前端
simon_luv_pho8 小时前
一行代码把网页变成 AI Agent?
前端
兆子龙8 小时前
模块联邦(Module Federation)详解:从概念到手把手 Demo
前端·架构