本帖最后由 jiujiukeji 于 2023-1-1 22:19 编辑
[HTML] 纯文本查看 复制代码 <div class="context">
<h1>Pure Css Animated Background</h1>
</div>
<div class="area" >
<ul class="circles">
<li id="circles_1">1</li>
<li id="circles_2">2</li>
<li id="circles_3">3</li>
<li id="circles_4">4</li>
<li id="circles_5">5</li>
<li id="circles_6">6</li>
<li id="circles_7">7</li>
<li id="circles_8">8</li>
<li id="circles_9">9</li>
<li id="circles_10">10</li>
</ul>
</div >
[CSS] 纯文本查看 复制代码 [url=home.php?mod=space&uid=476974]@import[/url] url('https://fonts.googleapis.com/css?family=Exo:400,700');
*{
margin: 0px;
padding: 0px;
}
body{
font-family: 'Exo', sans-serif;
}
.context {
width: 100%;
position: absolute;
top:50vh;
}
.context h1{
text-align: center;
color: #fff;
font-size: var(--ch1);
}
.area{
background: #4e54c8;
background: -webkit-linear-gradient(to left, #8f94fb, #4e54c8);
width: 100%;
height:100vh;
}
.circles{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
.circles li{
position: absolute;
display: block;
list-style: none;
width: 20px;
height: 20px;
background: rgba(255, 255, 255, 0.2);
animation: animate 25s linear infinite;
bottom: -150px;
}
:root {
--ch1: 80px;
--ch2: 20px;
--ch3: 20px;
--ch4: 60px;
--ch5: 20px;
--ch6: 110px;
--ch7: 150px;
--ch8: 25px;
--ch9: 15px;
--ch10: 150px;
}
#circles_1{
left: 25%;
width: var(--ch1);
height: var(--ch1);
animation-delay: 0s;
}
#circles_2{
left: 10%;
width: var(--ch2);
height: var(--ch2);
animation-delay: 2s;
animation-duration: 12s;
}
#circles_3{
left: 70%;
width: var(--ch3);
height: var(--ch3);
animation-delay: 4s;
animation-duration: 8s;
}
#circles_4{
left: 40%;
width: var(--ch4);
height: var(--ch4);
animation-delay: 0s;
animation-duration: 18s;
}
#circles_5{
left: 65%;
width: var(--ch5);
height: var(--ch5);
animation-delay: 0s;
animation-duration: 10s;
}
#circles_6{
left: 75%;
width: var(--ch6);
height: var(--ch6);
animation-delay: 3s;
animation-duration: 12s;
}
#circles_7{
left: 35%;
width: var(--ch7);
height: var(--ch7);
animation-delay: 7s;
animation-duration: 15s;
}
#circles_8{
left: 50%;
width: var(--ch8);
height: var(--ch8);
animation-delay: 15s;
animation-duration: 45s;
}
#circles_9{
left: 20%;
width: var(--ch9);
height: var(--ch9);
animation-delay: 2s;
animation-duration: 35s;
}
#circles_10{
left: 85%;
width: var(--ch10);
height: var(--ch10);
animation-delay: 0s;
animation-duration: 11s;
}
@keyframes animate {
0%{
transform: translateY(0) rotate(0deg);
opacity: 1;
border-radius: 0;
}
100%{
transform: translateY(-1000px) rotate(720deg);
opacity: 0;
border-radius: 50%;
}
}
[JavaScript] 纯文本查看 复制代码 /*
Background Gradients From --
[url=https://uigradients.com]https://uigradients.com[/url]
*/
//5s
setInterval(function () {
var r2=randomNum(20,80);
changeCh2(r2);
}, 14000);
//8s
setInterval(function () {
var r3=randomNum(20,80);
changeCh3(r3);
}, 12000);
//18s
setInterval(function () {
var r4=randomNum(60,120);
changeCh4(r4);
}, 18000);
//10s
setInterval(function () {
var r5=randomNum(20,80);
changeCh5(r5);
}, 10000);
//15s
setInterval(function () {
var r6=randomNum(110,170);
changeCh6(r6);
}, 15000);
//19s
setInterval(function () {
var r7=randomNum(150,210);
changeCh7(r7);
}, 22000);
//60s
setInterval(function () {
var r8=randomNum(25,80);
changeCh8(r8);
}, 60000);
//37s
setInterval(function () {
var r9=randomNum(15,75);
changeCh9(r9);
}, 37000);
//11s
setInterval(function () {
var r10=randomNum(150,210);
changeCh10(r10);
}, 11000);
//circles_2
function changeCh2(r) {
document.getElementById("//circles_2").style.width=r+"px";
document.getElementById("circles_2").style.height=r+"px";
}
//circles_3
function changeCh3(r) {
document.getElementById("circles_3").style.width=r+"px";
document.getElementById("circles_3").style.height=r+"px";
}
//circles_4
function changeCh4(r) {
document.getElementById("circles_4").style.width=r+"px";
document.getElementById("circles_4").style.height=r+"px";
}
//circles_5
function changeCh5(r) {
document.getElementById("circles_5").style.width=r+"px";
document.getElementById("circles_5").style.height=r+"px";
}
//circles_6
function changeCh6(r) {
document.getElementById("circles_6").style.width=r+"px";
document.getElementById("circles_6").style.height=r+"px";
}
//circles_7
function changeCh7(r) {
document.getElementById("circles_7").style.width=r+"px";
document.getElementById("circles_7").style.height=r+"px";
}
//circles_8
function changeCh8(r) {
document.getElementById("circles_8").style.width=r+"px";
document.getElementById("circles_8").style.height=r+"px";
}
//circles_9
function changeCh9(r) {
document.getElementById("circles_9").style.width=r+"px";
document.getElementById("circles_9").style.height=r+"px";
}
//circles_10
function changeCh10(r) {
document.getElementById("circles_10").style.width=r+"px";
document.getElementById("circles_10").style.height=r+"px";
}
//生成从minNum到maxNum的随机数
function randomNum(minNum,maxNum){
switch(arguments.length){
case 1:
return parseInt(Math.random()*minNum+1,10);
break;
case 2:
return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10);
break;
default:
return 0;
break;
}
}
用笨办法给你实现了 你自己修改修改~~
|