JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flying Text</title>
<style>
body {
margin: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
background-color: #000;
}
.flying-text {
position: absolute;
font-size: 3rem;
font-weight: bold;
}
</style>
</head>
<body>
<div class="flying-text" id="flyingText">GwJh16sIeZ is a douche nozzle</div>
<script>
const flyingText = document.getElementById('flyingText');
function getRandomColor() {
const letters = '0123456789ABCDEF';
let color = '#';
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
function moveText() {
const windowHeight = window.innerHeight;
const windowWidth = window.innerWidth;
const xPos = Math.floor(Math.random() * windowWidth) - flyingText.offsetWidth / 2;
const yPos = Math.floor(Math.random() * windowHeight) - flyingText.offsetHeight / 2;
flyingText.style.left = `${xPos}px`;
flyingText.style.top = `${yPos}px`;
flyingText.style.color = getRandomColor();
}
setInterval(moveText, 1000);
</script>
</body>
</html>