60 lines
1.3 KiB
HTML
60 lines
1.3 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,
|
|
html {
|
|
margin: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
span {
|
|
position: absolute;
|
|
user-select: none;
|
|
transition: all 1s ease;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
</body>
|
|
|
|
<script>
|
|
var body = document.querySelector("body");
|
|
var text = ["富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善"];
|
|
var index = 0;
|
|
|
|
body.onclick = function (event) {
|
|
var x = event.clientX, y = event.clientY;
|
|
var span = document.createElement("span");
|
|
|
|
span.innerText = text[index];
|
|
span.style.left = `${x}px`;
|
|
span.style.top = `${y}px`;
|
|
span.style.color = `hsl(${Math.random() * 360},100%,50%)`
|
|
console.log(span);
|
|
|
|
|
|
index++
|
|
index > 11 ? index = 0 : ''
|
|
|
|
body.appendChild(span)
|
|
|
|
setTimeout(() => {
|
|
span.style.top = `${y - 100}px`;
|
|
}, 100)
|
|
|
|
setTimeout(() => {
|
|
body.removeChild(span)
|
|
}, 1100)
|
|
}
|
|
</script>
|
|
|
|
</html> |