81 lines
1.5 KiB
HTML
81 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 {
|
|
height: 100vh;
|
|
}
|
|
|
|
body,
|
|
ul,
|
|
li {
|
|
margin: 0;
|
|
padding: 0;
|
|
list-style: none;
|
|
}
|
|
|
|
span {
|
|
position: fixed;
|
|
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
</body>
|
|
|
|
<script>
|
|
var textArr = ['富强', '民主', '文明', '和谐', '自由', '平等', '公正', '法治', '爱国', '敬业', '诚信', '友善'];
|
|
var index = 0;
|
|
|
|
|
|
$("body").onclick = function (e) {
|
|
var {x , y} = e;
|
|
var span = document.createElement("span");
|
|
span.innerText = textArr[index]
|
|
|
|
span.style = `
|
|
left:${x}px;
|
|
top: ${y}px;
|
|
|
|
`;
|
|
|
|
|
|
index++
|
|
index > 11 ? index = 0 :''
|
|
|
|
|
|
|
|
span.move = 0
|
|
|
|
$("body").appendChild(span)
|
|
|
|
function motion() {
|
|
span.move += 4;
|
|
if (span.move > 100) {
|
|
setTimeout(() => $("body").removeChild(span), 300)
|
|
// clearTimeout(time)
|
|
cancelAnimationFrame(time)
|
|
} else {
|
|
span.style.top = `${y - span.move}px`
|
|
time = requestAnimationFrame(motion)
|
|
}
|
|
}
|
|
|
|
motion ()
|
|
}
|
|
|
|
|
|
|
|
|
|
function $(className) {
|
|
return document.querySelector(className)
|
|
}
|
|
</script>
|
|
|
|
|
|
</html> |