Html设计小技巧之水滴效果

Html设计小技巧之水滴效果

        1. 效果展示

        2. 代码展示

        CSS代码:

* {
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background-color: rgb(144, 238, 144);
}

.water {
  /* 布局居中 */
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 200px;
  height: 200px;
  /* 设置液滴形状 */
  border-radius: 61% 39% 57% 43% / 46% 67% 33% 54%;
  /* 设置液滴阴影 */
  box-shadow: inset 10px 20px 30px rgba(128, 128, 128, 0.5),
    10px 10px 20px rgba(128, 128, 128, 0.3),
    15px 15px 30px rgba(128, 128, 128, 0.05),
    inset -10px -20px 30px rgba(192, 239, 192, 0.8);
  animation: waterRadius 3s linear infinite alternate;
}

/* 液滴反光 */
.water::before {
  content: '';
  position: absolute;
  top: 15%;
  left: 35%;
  width: 20px;
  height: 40px;
  transform: rotate(50deg);
  background-color: rgba(228, 251, 228, 0.8);
  border-radius: 46% 54% 36% 64% / 46% 43% 57% 54%;
  filter: blur(5px);
}

.water::after {
  content: '';
  position: absolute;
  top: 39%;
  left: 23%;
  width: 12px;
  height: 14px;
  background-color: rgba(228, 251, 228, 0.8);
  border-radius: 46% 54% 36% 64% / 46% 43% 57% 54%;
  filter: blur(4px);
}

/* 液滴动画 */
@keyframes waterRadius {
  25% {
    border-radius: 58% 42% 59% 41% / 52% 56% 54% 48%;
  }

  50% {
    border-radius: 46% 54% 40% 60% / 52% 33% 67% 48%;
  }

  75% {
    border-radius: 65% 35% 71% 29% / 31% 60% 40% 69%;
  }

  100% {
    border-radius: 60% 40% 43% 57% / 45% 51% 49% 55%;
  }
}

       HTML代码:

<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title>Html小技巧之水滴特效</title>
  <link rel="stylesheet" href="css/002.css">
</head>

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

</html>

  • 15
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值