更新第62个小实例

This commit is contained in:
DESKTOP-BM6RJU5\wyanh 2021-12-04 18:25:36 +08:00
parent e9304d2030
commit a4551d7fcb
4 changed files with 180 additions and 1 deletions

View File

@ -65,4 +65,5 @@
58. HTML5+CSS3小实例之有趣的心形加载动画
59. HTML5+CSS3小实例之侧边导航栏
60. HTML5+CSS3小实例之垂直卡片滑动动画
61. HTML5+CSS3小实例之纯CSS实现轮播图效果
61. HTML5+CSS3小实例之纯CSS实现轮播图效果
62. HTML5+CSS3小实例之流星划过天际的动画效果

150
css/62.css Normal file
View File

@ -0,0 +1,150 @@
*{
/* 初始化 */
margin: 0;
padding: 0;
}
body{
/* 100%窗口高度 */
height: 100vh;
/* 溢出隐藏 */
overflow: hidden;
}
.container{
/* 绝对定位 */
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: url("../images/space.jpg") no-repeat;
/* 把背景图像扩展至足够大,以使背景图像完全覆盖背景区域 */
background-size: cover;
/* 定位背景图像为正中间 */
background-position-x: center;
/* 执行动画:动画名称 时长 线性的 无限次播放 */
animation: animateBg 5s linear infinite;
}
span{
position: absolute;
top: 50%;
left: 50%;
width: 4px;
height: 4px;
background-color: #fff;
border-radius: 50%;
/* 发光效果 */
box-shadow: 0 0 0 4px rgba(255,255,255,0.1),
0 0 0 8px rgba(255,255,255,0.1),
0 0 20px rgba(255,255,255,1);
/* 执行动画 */
animation: animate 3s linear infinite;
}
/* 拖尾效果 */
span::before{
content: "";
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 300px;
height: 3px;
background: linear-gradient(90deg,#fff,transparent);
}
/* 接下来分别为每一个流星设置位置、动画延迟时间、动画时长 */
span:nth-child(1){
top: 0;
right: 0;
/* initial关键字用于设置CSS属性为它的默认值 */
left: initial;
/* 动画延迟时间 */
animation-delay: 0s;
/* 动画时长 */
animation-duration: 1s;
}
span:nth-child(2){
top: 0;
right: 80px;
left: initial;
animation-delay: 0.2s;
animation-duration: 3s;
}
span:nth-child(3){
top: 80px;
right: 0;
left: initial;
animation-delay: 0.4s;
animation-duration: 2s;
}
span:nth-child(4){
top: 0;
right: 180px;
left: initial;
animation-delay: 0.6s;
animation-duration: 1.5s;
}
span:nth-child(5){
top: 0;
right: 400px;
left: initial;
animation-delay: 0.8s;
animation-duration: 2.5s;
}
span:nth-child(6){
top: 0;
right: 600px;
left: initial;
animation-delay: 1s;
animation-duration: 3s;
}
span:nth-child(7){
top: 300px;
right: 0;
left: initial;
animation-delay: 1.2s;
animation-duration: 1.75s;
}
span:nth-child(8){
top: 0;
right: 700px;
left: initial;
animation-delay: 1.4s;
animation-duration: 1.25s;
}
span:nth-child(9){
top: 0;
right: 1000px;
left: initial;
animation-delay: 0.75s;
animation-duration: 2.25s;
}
span:nth-child(10){
top: 0;
right: 450px;
left: initial;
animation-delay: 2.75s;
animation-duration: 2.25s;
}
/* 定义动画 */
/* 背景缩放动画 */
@keyframes animateBg {
0%,100%{
transform: scale(1);
}
50%{
transform: scale(1.2);
}
}
/* 流星划过动画 */
@keyframes animate {
0%{
transform: rotate(315deg) translateX(0);
opacity: 1;
}
90%{
opacity: 1;
}
100%{
transform: rotate(315deg) translateX(-1000px);
opacity: 0;
}
}

28
html/62.html Normal file
View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>流星划过天际的动画效果</title>
<link rel="stylesheet" href="../css/62.css">
</head>
<body>
<div class="container">
<!-- 10个span -->
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</div>
</body>
</html>

BIN
images/space.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB