Files
ClassContent/历届学生/front-end-team-10/项目练习/学生项目/韩孟雪/2023-2-24/富强2.html
2024-09-27 02:06:13 +08:00

84 lines
2.2 KiB
HTML
Raw 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>富强2</title>
<style>
* {
margin: 0;
padding: 0;
}
span {
user-select: none;
position: fixed;
transition: all 1s;
}
.box{
width: 50px;
height: 50px;
border-radius: 100%;
background: red;
}
body {
height: 100vh;
}
</style>
</head>
<body>
</body>
<script>
// 产生文字
// 给网页绑定点击事件,获取到鼠标点击时候产生的 x y 坐标
// 使用下标来依次读取 数组中的文字,如果读完了回第一个继续轮回
// 使用 文字 生成 标签,并用js为标签设置定位,left top 距离 就是 xy 坐标
// 把生成好的 标签 放到 网页上,显示出来
// 让文字消失
var textArr = ["富强", "民主", "文明", "和谐", "自由", "平等", "公正" ,"法治", "爱国", "敬业", "诚信", "友善"];
var i = 0;
$("body").onclick = (e) =>{
//e是个对象 e = {}
var { x,y } = e;
//console.log( x,y );
//读数组
//console.log(textArr[i])
var span = document.createElement("div");
//把数组中的内容放到span的标签中
span.innerText = textArr[i]
span.style = `
color: hsla(${parseInt(Math.random() * 360)},100%,50%,1);
left:${x}px;
top: ${y}px;
`
console.log(span);
$("body").appendChild(div)
sport(span,y);
i++
if( i > 11){
i=0
}
}
function sport(span,y){
setTimeout(() => {
span.style.top = `${y-100}px`
}, 200)
setTimeout(() => {
$("body").removeChild(span)
}, 1350);
}
function $(className) {
return document.querySelector(className)
}
function _(className) {
return document.querySelectorAll(className)
}
</script>
</html>