[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>
<style>
div {
width: 200px;
height: 200px;
position: absolute;
}
</style>
</head>
<body>
<script>
document.documentElement.onmousemove = function (eve) {
var ev = window.eve || eve
var div = document.createElement("div")
console.log(div)
div.style.left = ev.clientX + "Px"
div.style.top = ev.clientY + "Px"
var r = Math.floor(Math.random() * (255 - 0 + 1) + 0)
var g = Math.floor(Math.random() * (255 - 0 + 1) + 0)
var b = Math.floor(Math.random() * (255 - 0 + 1) + 0)
div.style.backgroundColor = "rgb(" + r + "," + g + "," + b + ")"
document.body.appendChild(div)
}
</script>
</body>