demo.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>css3动画展示</title>
<link rel="stylesheet" href="demo.css">
</head>
<body>
<div>
<h2 class="monsterText">Hello
<br>There
</h2>
<h3>We will eat you</h3>
</div>
<div class="monster">
<div class="eye">
<div class="eyeBall"></div>
</div>
<div class="mouth"></div>
</div>
<div class="monster blue">
<div class="eye">
<div class="eyeBall"></div>
</div>
<div class="mouth"></div>
</div>
<div class="pageLoading">
<div class="monster">
<div class="eye">
<div class="eyeBall"></div>
</div>
<div class="mouth"></div>
</div>
<div class="loading">
<div class="bar"></div>
</div>
</div>
<script src="jquery-3.3.1.min.js"></script>
<script src="demo.js"></script>
</body>
</html>
demo.css
*{
padding: 0;
margin: 0;
}
html,body{
width: 100%;
height: 100%;
background-color: #db4d6d;
display: flex;
/* 水平居中 */
justify-content: center;
/* 垂直居中 */
align-items: center;
}
.monster{
position: relative;
width: 110px;
height: 100px;
border-radius: 20px;
background-color: #e55a54;
margin: 10px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
box-shadow: 0 10px 20px rgba(0, 0, 0, .2);
animation: jumping 0.8s infinite alternate;
}
.monster .eye{
width: 40%;
height: 40%;
border-radius: 50%;
background-color: #ffffff;
margin: 10px;
display: flex;
/* 水平居中 */
justify-content: center;
/* 垂直居中 */
align-items: center;
}
.monster .eye .eyeBall{
width: 50%;
height: 50%;
border-radius: 50%;
background-color: #0c4475;
animation: eyemove 1.6s infinite alternate;
}
.monster .mouth{
width: 32%;
height: 12px;
border-radius: 12px;
background-color: #ffffff;
}
.monster::before,.monster::after{
position: absolute;
content: "";
display: block;
width: 20%;
height: 10px;
border-radius: 10px;
background-color: #ffffff;
top: -10px;
left: 50%;
}
.monster::before{
transform: translateX(-70%) rotate(45deg);
}
.monster::after{
transform: translateX(-30%) rotate(-45deg);
}
.monster.blue{
animation-delay: 0.5s;
background-color: #0c4475;
}
.monster.monster.blue .eyeBall,.monster.blue .mouth{
background-color: #db4d6d;
}
@keyframes jumping{
50%{
top:0;
box-shadow: 0 10px 20px rgba(0, 0, 0, .2);
}
100%{
top: -50px;
box-shadow: 0 120px 20px rgba(0, 0, 0, .1);
}
}
@keyframes eyemove{
0%,10%{
transform: translateX(50%);
}
90%,100%{
transform: translateX(-50%);
}
}
.pageLoading{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #0c4475;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
transition: opacity 0.5s;
}
.pageLoading .loading{
width: 200px;
height: 8px;
background-color: #ffffff;
border-radius: 5px;
margin-top: 50px;
overflow: hidden;
}
.pageLoading .loading .bar{
width: 0%;
height: 100%;
background-color: #db4d6d;
}
.pageLoading.complete{
opacity: 0;
}
.pageLoading.complete .monster{
transition: 0.5s;
transform: scale(0.1) rotateZ(360deg);
}