制作跳动的爱心网页效果

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

效果:

相关推荐
qq_5470261792 小时前
Flowable 工作流引擎
java·服务器·前端
刘逸潇20053 小时前
CSS基础语法
前端·css
吃饺子不吃馅4 小时前
[开源] 从零到一打造在线 PPT 编辑器:React + Zustand + Zundo
前端·svg·图形学
小马哥编程5 小时前
【软考架构】案例分析-Web应用设计(应用服务器概念)
前端·架构
鱼与宇5 小时前
苍穹外卖-VUE
前端·javascript·vue.js
啃火龙果的兔子5 小时前
前端直接渲染Markdown
前端
z-robot5 小时前
Nginx 配置代理
前端
用户47949283569155 小时前
Safari 中文输入法的诡异 Bug:为什么输入 @ 会变成 @@? ## 开头 做 @ 提及功能的时候,测试同学用 Safari 测出了个奇怪的问题
前端·javascript·浏览器
没有故事、有酒5 小时前
Ajax介绍
前端·ajax·okhttp
朝新_5 小时前
【SpringMVC】详解用户登录前后端交互流程:AJAX 异步通信与 Session 机制实战
前端·笔记·spring·ajax·交互·javaee