<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{
margin: 0;
padding: 0;
list-style: none;
}
body{
background-color: #000;
overflow: hidden;
}
span{
width: 30px;
height: 30px;
border-radius: 50%;
position: absolute;
background-size:100% 100%;
animation: flash 1s alternate infinite;
}
@keyframes flash {
0%{opacity: 0;}
100%{opacity: 1;}
}
span:hover{
animation:none;
}
</style>
</head>
<body>
<span></span>
<script>
window.onload = function () {
// 屏幕的尺寸
var screenW = document.documentElement.clientWidth;
var screenH = document.documentElement.clientHeight;
//动态创建多个圆
for(var i=0; i<150; i++){
var span = document.createElement('span');
document.body.appendChild(span);
//位置随机
var x = parseInt(Math.random() * screenW);
var y = parseInt(Math.random() * screenH);
span.style.left = x + 'px';
span.style.top = y + 'px';
//大小随机
var scale = Math.random() * 1.5;
span.style.transform = 'scale('+ scale + ', ' + scale + ')';
//频率随机
var rate = Math.random() * 1.5;
span.style.animationDelay = rate + 's';
//颜色随机
var color = '#'+Math.floor(Math.random()*16777215).toString(16);
span.style.background = color;
}
}
</script>
</body>
</html>
因篇幅问题不能全部显示,请点此查看更多更全内容