酷代码 AI
菜单
全部AI  /  热门  /  AI写代码神器
服务商

<!doctype html> <html> <head> <title>code rain with dragon</title> <style> body { background-color: #000; overflow: hidden; font-family: monospace; color: #0f0; } #dragon { position: absolute; top:50%; left:50%; transform: translate(-50%, -50%); font-size:30px; } .code { position: absolute; color: #0f0; } </style> </head> <body> <div id="dragon"></div> <script> const dragon = document.getelementbyid('dragon'); const coderain = []; const codechars = 'abcdefghijklmnopq

It looks like your script was cut off! Here's the completed version of your code to generate "coderain" with a dragon symbol in the center: ```html <!doctype html> <html> <head> <title>Code Rain with Dragon</title> <style> body { background-color: #000; overflow: hidden; font-family: monospace; color: #0f0; } #dragon { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 30px; } .code { position: absolute; color: #0f0; } </style> </head> <body> <div id="dragon"></div> <script> const dragon = document.getElementById('dragon'); const codeRain = []; const codeChars = 'abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWYZ1234567890'; // Set up the code rain for (let i = 0; i < 100; i++) { const x = Math.random() * window.innerWidth; const y = Math.random() * window.innerHeight; codeRain.push({ x, y, speed: Math.random() * 10 + 1 }); } // Update the code rain every 50 milliseconds setInterval(() => { codeRain.forEach(drop => { drop.y += drop.speed; if (drop.y > window.innerHeight) { drop.y = -drop.speed; } const el = document.createElement('span'); el.textContent = codeChars[Math.floor(Math.random() * codeChars.length)]; el.style.left = `${drop.x}px`; el.style.top = `${drop.y}px`; document.body.appendChild(el); setTimeout(() => { el.remove(); }, 1000); }); }, 50); // Display the dragon dragon.textContent = '🐲'; // You can replace this with any other symbol or text </script> </body> </html> ``` This script generates a "code rain" effect with green characters falling down the screen and a dragon symbol displayed in the center. The `codeRain` array holds the positions and speeds of each "drop" of code. The setInterval function updates the positions of the drops every 50 milliseconds, creating the illusion of movement. Each drop is created as a span element that is appended to the body and then removed after 1 second. Feel free to adjust the parameters (like the number of drops or the speed) to fit your needs! [2024-08-23 20:17:08 | AI写代码神器 | 537点数解答]

相关提问