<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
const img_w = 254
const img_h = 218
document.body.style.backgroundColor = "#000"
window.onload = function(){
document.onclick = function(event){
console.info(event.pageX)
console.info(event.pageY)
let img = document.createElement("img")
img.src ="https://www.jiachong.com/uploads/allimg/210322/1153004040-0.gif"
img.style.position = "absolute"
w = getRandom(20,200)
img.style.width = w + "px"
h = w * img_h / img_w
img.style.height = h + "px"
img.style.left = (event.pageX - w / 2) + "px"
img.style.top = (event.pageY - h / 2) + "px"
document.body.appendChild(img)
}
}
function getRandom(min,max){
return min + Math.ceil((max-min) * Math.random())
}
</script>
</body>
</html>
点哪里亮哪里的星星
最新推荐文章于 2024-09-17 11:42:54 发布