首页 技术 正文
技术 2022年11月15日
0 收藏 630 点赞 2,469 浏览 1782 个字

GIF图有点大,网速慢的或将稍等片刻或可浏览本人的制作的demo。

Demo : 点击查看

【CSS3 + 原生JS】上升的方块动态背景

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Glunefish</title>
<link rel="stylesheet" href="css/style.css" rel="external nofollow" >
</head>
<body>
<div id="F-dynamicbg-box">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</body>
</html>

CSS:

    * {
margin:; padding:; border: none; outline:;
}
body{
width: 100vw;
height: 100vh;
background: url(img/bg.png) no-repeat;
background-size: cover;
}
#F-dynamicbg-box {
width: 100vw;
height: 100vh;
position: absolute;
top:;
left:;
overflow: hidden;
}
#F-dynamicbg-box > div {
z-index: -9999;
background-color: rgba(255,255,255,.1);
position: absolute;
top: 105vh;
animation: dynamicDiv 30s linear infinite;
}
#F-dynamicbg-box > div:nth-of-type(1) { animation-delay: 1s }
#F-dynamicbg-box > div:nth-of-type(2) { animation-delay: 3s }
#F-dynamicbg-box > div:nth-of-type(3) { animation-delay: 6s }
#F-dynamicbg-box > div:nth-of-type(4) { animation-delay: 9s }
#F-dynamicbg-box > div:nth-of-type(5) { animation-delay: 12s }
#F-dynamicbg-box > div:nth-of-type(6) { animation-delay: 4s }
#F-dynamicbg-box > div:nth-of-type(7) { animation-delay: 15s }
#F-dynamicbg-box > div:nth-of-type(8) { animation-delay: 18s }
#F-dynamicbg-box > div:nth-of-type(9) { animation-delay: 20s }
#F-dynamicbg-box > div:nth-of-type(10) { animation-delay: 16s } @keyframes dynamicDiv {
form { top: 105vh; transform: scale(1.2); }
to { top: -13vh; transform: scale(1) rotate(60deg); }
}

JS:( JS初始化div形态 )

        var box = document.getElementById('F-dynamicbg-box'),
div = box.getElementsByTagName('div'),
math = [0,1];for (var i=0;i<div.length;i++) {
math[1] = F_getSJS(100,40,9) F_getSJS 请移步博客之前的取随机数了解
if(math[1] != math[2]){
div[i].style.width = math[1] + 'px';
div[i].style.height = math[1] + 'px';
math[2] = math[1];
}
} for(var i=0;i<div.length;i++){
div[i].style.left = F_getSJS(85,15,8) + 'vw';
div[i].style.transform = 'rotate(' + F_getSJS(360,5,9) + 'deg)';
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,000
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,512
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,358
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,141
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,771
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,849