制作跳动的爱心网页效果

html

复制代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>跳动的爱心</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="heart">
  <div class="petal"></div>
  <div class="petal"></div>
</div>
<script src="script.js"></script>
</body>
</html>

css (命名为styles.css)

复制代码
body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: #f7f7f7;
}

.heart {
  position: relative;
  width: 100px;
  height: 90px;
  transform: rotate(45deg);
}

.petal {
  position: absolute;
  top: 0;
  width: 52px;
  height: 80px;
  border-radius: 50px 50px 0 0;
  background: red;
}

.petal:first-child {
  left: 50px;
  border-bottom-right-radius: 40px 50px;
  transform: rotate(-45deg);
  transform-origin: 0 100%;
}

.petal:last-child {
  left: 0;
  border-top-left-radius: 50px 45px;
  transform: rotate(45deg);
  transform-origin: 100% 100%;
}

@keyframes heartbeat {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.heart {
  animation: heartbeat 1s infinite;
}

效果:

相关推荐
疯华整猫1 小时前
被杀掉之后:我把 Android 的「唤起 + 常驻」重做了一遍
前端·面试·架构
IT_陈寒3 小时前
Java开发实战:从入门到精通
前端·人工智能·后端
风骏时光牛马3 小时前
生成一个AI转岗经历标题,只需要一个标题,不需要其他的任何文本。
前端
Csvn12 小时前
Monorepo
前端
Csvn12 小时前
流水线
前端
Csvn12 小时前
微前端架构
前端
Linux-lucky14 小时前
45-Linux学习之旅之防火墙与WEB加固
linux·前端·网络·学习·ubuntu
风骏时光牛马16 小时前
生成一个移动端标题,只需要一个标题,不需要其他的任何文本。
前端
IT_陈寒17 小时前
Redis雪崩把我坑惨了,这是5年经验的教训
前端·人工智能·后端
SameX17 小时前
HarmonyOS ArkUI List 的侧滑删除 用 ListItem 的 swipeAction + endIcon 的做法
前端