制作跳动的爱心网页效果

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;
}

效果:

相关推荐
@PHARAOH1 小时前
WHAT - GitLens vs Fork
前端
yqcoder2 小时前
前端性能优化:如何减少重绘与重排?
前端·性能优化
洋子2 小时前
Yank Note 系列 13 - 让 AI Agent 进入笔记工作流
前端·人工智能
wenzhangli75 小时前
Ooder A2UI 核心架构深度解析:WEB 拦截层的设计与实现
前端·架构
前端百草阁5 小时前
【前端性能优化全链路指南】从开发编写到构建运行的多维度实践
前端·性能优化
女生也可以敲代码5 小时前
AI时代下的50道前端开发面试题:从基础到大模型应用
前端·面试
ZhengEnCi5 小时前
M5-markconv自定义CSS样式指南 📝
前端·css·python
IT_陈寒6 小时前
SpringBoot自动配置的坑差点让我加班到天亮
前端·人工智能·后端
xingpanvip6 小时前
星盘接口开发文档:星相日历接口指南
android·开发语言·前端·css·php·lua
@PHARAOH6 小时前
WHAT - GitLens supercharged 插件
前端