53 lines
1.0 KiB
HTML
53 lines
1.0 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>红包</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
img {
|
|
width: 80px;
|
|
height: 96px;
|
|
position: fixed;
|
|
top: 0;
|
|
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<!-- <img src="./hb.png" alt=""> -->
|
|
</body>
|
|
<script>
|
|
var { clientWidth, clientHeight } = document.body;
|
|
|
|
function CreateHB() {
|
|
var img = document.createElement("img")
|
|
img.src = "./hb.png";
|
|
var x = Math.random() * (clientWidth - 80)
|
|
console.log('x', x, clientWidth);
|
|
img.style.left = `${x}px`;
|
|
$('body').appendChild(img)
|
|
console.log("./hb.png:", img);
|
|
}
|
|
// setInterval(() => {
|
|
CreateHB()
|
|
// },1000
|
|
// )
|
|
|
|
|
|
|
|
|
|
function $(className) {
|
|
return document.querySelector(className)
|
|
}
|
|
</script>
|
|
|
|
</html> |