Files
2024-09-27 02:06:13 +08:00

65 lines
1.5 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>富强</title>
<style>
body {
height: 100vh;
position: relative;
}
span {
position: absolute;
transition: all 1s;
user-select: none;
}
</style>
</head>
<body>
</body>
<script>
var index = 0;
var text = ["富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善"]
var body = document.querySelector("body")
body.onclick = function (e) {
var x = e.x,
y = e.y;
var span = document.createElement("span")
span.innerText = text[index]
span.style = `
left: ${x}px;
top: ${y}px;
color: hsla(${parseInt(Math.random() * 360)},100%,50%,1);
`
body.appendChild(span)
motion(span)
index++
if (index > 11) {
index = 0
}
}
function motion(el) {
// 让span 的top 自减 150px也就是向上运动
setTimeout(function() {
el.style.top = `${parseInt(el.style.top) - 150}px`
}, 100)
// 运动完成后从body中删除这个span标签
setTimeout(function() {
body.removeChild(el)
}, 1200)
}
</script>
</html>