Files
ClassContent/历届学生/逯帅帅/项目开发/学生项目/谢文军/demo1/page/richandstrong.html
2024-09-27 02:06:13 +08:00

57 lines
1.4 KiB
HTML

<!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>rich and strong</title>
<style>
body,
html {
height: 100%;
}
</style>
</head>
<body>
</body>
<script>
var index = 0;
var body = document.querySelector("body")
body.onclick = function (event) {
// console.log(event)
var x = event.x;
var Y = event.y;
var Text = ["富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善"];
index > 11 ? index = 0 : '';
// console.log(Text[index])
var span = document.createElement("span");
span.innerText = Text[index];
span.style = `
position: fixed;
left: ${x}px;
top: ${Y}px;
transition: all ease 1s;
opacity: 1;
color: hsla(${parseInt(Math.random() * 360)},100%,50%);`;
body.appendChild(span)
console.log(span)
animation(span,Y);
index++
}
function animation(a,y) {
setTimeout(function (){
a.style.opacity = 0
a.style.top = `${y-100}px`
},100)
setTimeout(function (){
body.removeChild(a)
},1100)
}
</script>
</html>