62 lines
1.0 KiB
HTML
62 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>Document</title>
|
|
</head>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
img {
|
|
width: 70px;
|
|
height: 90px;
|
|
top: 0;
|
|
}
|
|
|
|
body {
|
|
height: 100vh;
|
|
}
|
|
</style>
|
|
|
|
<body>
|
|
|
|
</body>
|
|
|
|
<script>
|
|
var { clientWidth, clientHeight } = document.body;
|
|
var offsetLeft = clientWidth - 70;
|
|
|
|
function createdHB() {
|
|
var randomLeft = Math.random() * offsetLeft;
|
|
var img = document.createElement("img");
|
|
|
|
img.src = "./hb.png";
|
|
img.style = `
|
|
left:${randomLeft}px;
|
|
`
|
|
$("body").appendChild(img)
|
|
}
|
|
|
|
|
|
setInterval(() => {
|
|
createdHB()
|
|
}, 2000)
|
|
|
|
|
|
function $(className) {
|
|
return document.querySelector(className)
|
|
}
|
|
|
|
function _(className) {
|
|
return document.querySelectorAll(className)
|
|
}
|
|
|
|
</script>
|
|
|
|
</html> |