怎样用最简单的html+css代码制作一颗跳动的心?

来源:互联网 发布:知乎机构账号怎么注销 编辑:程序博客网 时间:2024/06/09 23:25
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>心</title>

<script src="js/jquery.min.js"></script>

<style>

* {
margin:0;
padding: 0;
}
body {
background-color: #000;
}
h2 {
    width: 220px;
    margin: 20px auto;
    color: #f00;
}
.heart {
width: 200px;
height: 200px;
position: relative; 
margin:0 auto;
top:30px;
animation: heart 0.5s  0s infinite; 
}
.left, .right {
width: 200px;
height: 200px;
background: #FA8383;
border-radius: 100px 100px 0 0;
position: absolute;
box-shadow: 0px 0px 50px #FA8383; 
}
.bottom {
width: 200px;
height: 200px;
background: #FA8383;
position: absolute;
box-shadow:0px 0px 50px #FA8383;  
transform: translate(0,64px) rotate(45deg) scale(0.9,0.9);   
}
.left {
transform: translate(-50px,0) rotate(-45deg);
}
.right {
transform: translate(50px,0) rotate(45deg); 
}
/*定义动画*/
@keyframes heart {
from {
transform:scale(1,1);
}
to {
transform:scale(1.5,1.5);
}
}

</style>

</head>
<body>
    <h2>扑通扑通的小心心</h2>
<div class="heart">
<div class="left"></div>
<div class="right"></div>
<div class="bottom"></div>
</div>
</body>
</html>