利用css3实现了心形效果,并且还能够跳动。
代码实例如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>web前端开发学习q群:767273102 技术分享,欢迎基础小伙伴</title>
<style type="text/css">
#myheart {
position: relative;
width: 150px;
height: 220px;
}
#myheart:before,#myheart:after {
position: absolute;
left: 100px;
background: red;
height: 160px;
width: 100px;
content: "";
border-radius: 50px 50px 0 0;
transform: rotate(-45deg);
transform-origin: 0 100%;
}
#myheart:after {
left: 0;
transform: rotate(45deg);
transform-origin: 100% 100%;
}
@keyframes heart {
0% {
-webkit-transform: scale(1);
}
50% {
-webkit-transform: scale(0.8);
}
100% {
-webkit-transform: scale(1);
}
}
.myheart {
position: absolute;
top: 40%;
left: 40%;
animation: heart 1.5s linear infinite;
}
</style>
</head>
<body>
<div class="myheart">
<div id="myheart"></div>
</div>
</body>
</html>
原文地址:https://blog.51cto.com/14458119/2427446
时间: 2024-10-09 18:42:56