一、Css3+jquery 实现loading加载动画
这是一个 Loading 加载demo 不需要图片 纯html和css 实现样式
以下是html css以及js的代码 需要自取
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Demo</title>
<link rel="stylesheet" href="demo.css">
</head>
<body>
<div>
<h2 class="monsterText">Hello <br/>There</h2>
<h3>We will eat you</h3>
</div>
<!-- 怪物1 -->
<div class="monster">
<div class="eye">
<div class="eyeBall"></div>
</div>
<div class="mouth"></div>
</div>
<!-- 怪物2 -->
<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="js/jquery-3.6.0.min.js"></script>
<script src="js/demo.js"></script>
</body>
</html>
css3
* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
height: 100%;
background-color: #FF6A6A;
display: flex;
/* 水平 */
justify-content: center;
/* 垂直 */
align-items: center;
}
.monster {
width: 110px;
height: 100px;
border-radius: 20px;
background-color: #FF6347;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
margin: 10px;
/* 动画名称 动画时长 持续运动 后续动画的一个缓冲 */
animation: jumping 0.8s infinite alternate;
}
.monster .eye {
width: 40%;
height: 40%;
border-radius: 50%;
background-color: #fff;
margin: 10px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.monster .eye .eyeBall {
width: 50%;
height: 50%;
border-radius: 50%;
background-color: #0c4475;
/* 0-50% -50%-0 都有动画 */
animation: eyemove 1.6s infinite alternate;
}
.monster .mouth {
width: 35%;
height: 12px;
border-radius: 12px;
background-color: #fff;
}
.monster::before,
.monster::after {
position: absolute;
content: '';
display: block;
width: 20%;
height: 10px;
border-radius: 10px;
background-color: #fff;
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.blue .eyeBall,
.monster.blue .mouth {
background-color: #FF6347;
}
@keyframes jumping {
50% {
top: 0;
/* x y 距离 颜色值 */
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}
100% {
top: -50px;
box-shadow: 0 120px 20px rgba(0, 0, 0, 0.1);
}
}
@keyframes eyemove {
0%,
10% {
transform: translate(50%);
}
90%,
100% {
transform: translate(-50%);
}
}
/* 加载遮罩层 */
.pageLoading {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: #0c4475;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
transition: opacity 1s;
}
.pageLoading .loading {
width: 200px;
height: 8px;
background-color: #fff;
border-radius: 5px;
margin-top: 50px;
overflow: hidden;
}
.pageLoading .loading .bar {
width: 0%;
height: 100%;
background-color: #FF6A6A;
}
.pageLoading.complete {
opacity: 0;
}
.pageLoading.complete .monster {
transition: 0.5s;
transform: scale(0.1) rotateZ(360deg);
}
h2,
h3 {
color: #fff;
}
js代码
// 定义百分比
var per = 0
var timer;
// setInterval 每隔一段时间调用
timer = setInterval(function() {
$('.bar').css('width', per + '%');
per += 1;
if (per > 100) {
$('.pageLoading').addClass('complete');
setTimeout(function() {
$('.monsterText').html('<h2>We Are Monster</h2>')
}, 3000)
clearInterval(timer);
}
}, 30)
不要忘记引入jquery文件
(2021年9月9日学习 demo 记录)
9:00-12:00
1.今天做了一个css3小demo
2.学习了如何制作gif图
14:00-18:00
1.做了一个canvas 生成验证码登录
2.自己找的图片素材,ps的