64 lines
1.5 KiB
HTML
64 lines
1.5 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>Document</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
height: 100vh;
|
|
position: relative;
|
|
}
|
|
|
|
span {
|
|
position: absolute;
|
|
transition: all 1s;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
</body>
|
|
<script>
|
|
function $(name) {
|
|
return document.querySelector(name);
|
|
}
|
|
function _(name) {
|
|
return document.querySelectorAll(name);
|
|
}
|
|
let text = ['富强', '民主', '文明', '和谐', '自由', '平等', '公正', '法治', '爱国', '敬业', '诚信', '友善'],
|
|
index = 0;
|
|
$("body").onclick = function (e) {
|
|
index += 1;
|
|
let span = document.createElement("span");
|
|
span.innerText = text[index]
|
|
if (index >= 11) {
|
|
index = 0;
|
|
}
|
|
let { x, y } = e
|
|
span.style = `left: ${x}px;top: ${y}px;color: hsl(${Math.random() * 360}, 100%, 50%);`
|
|
$("body").appendChild(span)
|
|
qwe(span, y)
|
|
}
|
|
let sc = 0
|
|
function qwe(q, y) {
|
|
setTimeout(function () {
|
|
q.style.top = `${y + Math.random() * 200}px`
|
|
}, 400);
|
|
let ssd = _("span");
|
|
console.log(ssd)
|
|
sc += 1
|
|
if (sc > 12) {
|
|
setTimeout(function () {
|
|
$("body").removeChild(ssd[0]);
|
|
}, )
|
|
}
|
|
}
|
|
</script>
|
|
|
|
</html> |