<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
<title>纯CSS实现动态精灵示爱浪漫动画特效代码</title>
<meta name="keywords" content="纯CSS,动态精灵,示爱,浪漫动画,特效代码" />
<meta name="description" content="纯CSS实现动态精灵示爱浪漫动画特效代码下载。" />
<meta name="author" content="php中文网(www.php.cn)" />
<meta name="copyright" content="php中文网(www.php.cn)" />
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<div class="egg">
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<div class="face">
<div class="eyes"></div>
<div class="smile"></div>
<div class="cheeks"></div>
<div class="shine"></div>
</div>
</ul>
</div>
<div class="shadow" id="egg-shadow"></div>
<div class="heart">
<div class="light"></div>
</div>
<div class="ghost">
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<div class="face">
<div class="eyes"></div>
<div class="smile"></div>
<div class="cheeks"></div>
</div>
</div>
<div class="shadow" id="ghost-shadow"></div>
</div>
</body>
</html>
@import url("https://fonts.googleapis.com/css?family=Josefin+Sans:300");
body {
background: #48befe;
font-family: 'Josefin Sans', sans-serif;
font-size: 12px;
}
.container {
position: absolute;
white-space: nowrap;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
ul {
margin: 0;
padding: 0;
}
ul li {
list-style: none;
}
.egg {
width: 175px;
height: 220px;
border-radius: 100px 100px 0px 0px;
background: #fdfeff;
position: relative;
display: inline-block;
animation: floating 5s ease-out infinite;
left: -5%;
}
.egg .face {
width: 130px;
height: 130px;
background: #ffdb10;
position: absolute;
margin: 15% 15%;
border-radius: 100%;
box-shadow: inset -10px 1px 0 #ffcc24;
}
.egg .face .eyes {
width: 15px;
height: 15px;
background: #000;
border-radius: 100%;
position: relative;
top: 55px;
left: 38px;
animation: blink 3s infinite 2s;
}
.egg .face .eyes::after {
content: "";
width: 15px;
height: 15px;
position: absolute;
background: #000;
border-radius: 100%;
left: 50px;
}
.egg .face .smile {
position: relative;
border-bottom-left-radius: 90px;
border-bottom-right-radius: 90px;
width: 30px;
height: 15px;
background: #000;
left: 55px;
top: 60px;
}
.egg .face .smile::after {
content: "";
position: absolute;
width: 10px;
height: 5px;
background: #ff7e7e;
border-radius: 100%;
left: 10px;
top: 8px;
}
.egg .face .cheeks {
position: relative;
width: 12px;
height: 12px;
background: #ff7e7e;
border-radius: 100%;
opacity: 0.5;
top: 40px;
left: 30px;
}
.egg .face .cheeks::after {
content: "";
position: absolute;
width: 12px;
height: 12px;
background: #ff7e7e;
border-radius: 100%;
left: 67px;
}
.egg .face .shine {
position: relative;
width: 8px;
height: 20px;
background: #fdfeff;
border-radius: 200px;
top: -10px;
left: 12px;
transform: rotate(20deg);
}
.egg .face .shine::after {
position: absolute;
content: "";
width: 8px;
height: 8px;
background: #fdfeff;
border-radius: 200px;
top: -15px;
left: 6px;
}
.egg ul {
display: flex;
}
.egg li {
position: relative;
border-radius: 200px;
}
.egg li:nth-child(odd) {
background: #fdfeff;
}
.egg li:nth-child(even) {
background: #48befe;
}
.egg li:nth-child(1) {
width: 30px;
height: 60px;
top: 175px;
animation: anim1 1.5s ease-out infinite;
}
.egg li:nth-child(2) {
width: 20px;
height: 50px;
top: 185px;
animation: anim2 3s ease-out infinite;
}
.egg li:nth-child(3) {
width: 28.5px;
height: 60px;
top: 195px;
animation: anim3 1s ease-in-out infinite;
}
.egg li:nth-child(4) {
width: 20px;
height: 50px;
top: 210px;
animation: anim4 2.2s ease-out infinite;
}
.egg li:nth-child(5) {
width: 28.5px;
height: 60px;
top: 190px;
animation: anim3 1.5s ease-out infinite;
}
.egg li:nth-child(6) {
width: 20px;
height: 60px;
top: 200px;
animation: anim2 4s ease-out infinite;
}
.egg li:nth-child(7) {
width: 28.5px;
height: 60px;
top: 190px;
animation: anim1 1.5s ease-out infinite;
}
.ghost {
width: 175px;
height: 220px;
border-radius: 100px 100px 0px 0px;
background: #fdfeff;
position: relative;
display: inline-block;
animation: floating 2s ease-out infinite;
opacity: 0.75;
left: 5%;
}
.ghost::before {
content: "";
width: 175px;
height: 220px;
border-radius: 100px 100px 0px 0px;
background: #fdfeff;
position: relative;
display: inline-block;
position: absolute;
box-shadow: inset -15px 1px 0px #efefef;
}
.ghost .face {
width: 130px;
height: 130px;
background: transparent;
position: absolute;
margin: -20% 10%;
border-radius: 100%;
}
.ghost .face .eyes {
opacity: 0.5;
width: 15px;
height: 15px;
background: #000;
border-radius: 100%;
position: relative;
top: 55px;
left: 3px;
animation: blink 5s infinite;
}
.ghost .face .eyes::after {
content: "";
width: 15px;
height: 15px;
position: absolute;
background: #000;
border-radius: 100%;
left: 50px;
}
.ghost .face .smile {
position: relative;
opacity: 0.5;
border-bottom-left-radius: 50px;
border-bottom-right-radius: 50px;
width: 10px;
height: 6px;
background: transparent;
border: 5px solid #000;
left: 25px;
top: 55px;
}
.ghost .face .smile::before {
background: #fdfeff;
width: 30px;
height: 7px;
content: "";
position: absolute;
left: -10px;
top: -5.5px;
}
.ghost .face .cheeks {
position: relative;
width: 12px;
height: 12px;
background: #ff7e7e;
border-radius: 100%;
opacity: 0.5;
top: 43px;
left: -4px;
}
.ghost .face .cheeks::after {
content: "";
position: absolute;
width: 12px;
height: 12px;
background: #ff7e7e;
border-radius: 100%;
left: 67px;
}
.ghost ul {
display: flex;
}
.ghost li {
position: relative;
border-radius: 200px;
height: 60px;
}
.ghost li:nth-child(odd) {
background: #fdfeff;
width: 30px;
top: 172px;
z-index: -1;
}
.ghost li:nth-child(even) {
background: #48befe;
width: 7px;
top: 215px;
}
.ghost li:nth-child(1) {
animation: ghostani 3s ease-out infinite;
}
.ghost li:nth-child(3) {
animation: ghostani 3s ease-out infinite 0.5s;
}
.ghost li:nth-child(5) {
animation: ghostani 3s ease-out infinite 1.0s;
}
.ghost li:nth-child(7) {
animation: ghostani 3s ease-out infinite 1.5s;
}
.ghost li:nth-child(9) {
box-shadow: inset -15px 4px #efefef;
animation: ghostani 3s ease-out infinite 2s;
}
.heart {
position: absolute;
display: inline-block;
width: 30px;
height: 30px;
background: red;
left: 45%;
transform: rotate(45deg);
animation: beat 0.7s linear infinite;
}
.heart::before, .heart::after {
position: absolute;
content: "";
width: 30px;
height: 30px;
background: red;
border-radius: 100%;
top: -50%;
animation: beat 0.7s linear infinite;
}
.heart::after {
top: 0%;
left: -50%;
}
.heart .light {
width: 5px;
height: 12px;
background: white;
position: absolute;
border-radius: 200px;
z-index: 3;
left: -11px;
top: 13px;
transform: rotate(-10deg);
animation: lightshift 0.7s linear infinite;
}
.heart .light::after {
content: "";
position: absolute;
z-index: 3;
width: 5px;
height: 5px;
background: white;
border-radius: 200px;
top: -5px;
left: 1.5px;
}
.shadow {
position: absolute;
opacity: 0.2;
width: 180px;
height: 15px;
background: #000;
top: 275px;
border-radius: 100%;
}
.shadow#egg-shadow {
left: -20px;
animation: shadow-ani 5s ease-out infinite;
}
.shadow#ghost-shadow {
left: 195px;
transform-origin: center;
animation: shadow-ani 2s ease-out infinite;
}
@keyframes shadow-ani {
50% {
width: 170px;
height: 10px;
}
}
@keyframes blink {
0% {
transform: scaleY(1);
}
18% {
transform: scaleY(1);
}
20% {
transform: scaleY(0);
}
25% {
transform: scaleY(1);
}
38% {
transform: scaleY(1);
}
40% {
transform: scaleY(0);
}
45% {
transform: scaleY(1);
}
80% {
transform: scaleY(1);
}
}
@keyframes beat {
20%,
40% {
height: 40px;
width: 40px;
}
}
@keyframes lightshift {
20%,
40% {
left: -15px;
}
}
@keyframes floating {
0% {
top: 0;
}
50% {
top: -10px;
}
100% {
top: 0;
}
}
@keyframes anim1 {
50% {
top: 180px;
}
}
@keyframes anim2 {
50% {
top: 178px;
}
}
@keyframes anim3 {
50% {
top: 205px;
}
}
@keyframes anim4 {
50% {
top: 205px;
}
}
@keyframes ghostani {
50% {
top: 180px;
}
}
祝各位朋友表白成功