Dynamische HTML-Animation beim Öffnen
Hier ist eine faszinierende HTML-Anwendung mit dynamischen Animationen, die beim Öffnen starten. Diese Kombination aus Partikeleffekten, fließenden Formen und Farbverläufen schafft ein beeindruckendes visuelles Erlebnis.
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dynamische Animation</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background: linear-gradient(135deg, #1a1a2e, #16213e);
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
font-family: 'Arial', sans-serif;
color: white;
cursor: none;
}
#canvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
.content {
position: relative;
z-index: 1;
text-align: center;
max-width: 800px;
padding: 20px;
background: rgba(0, 0, 0, 0.3);
border-radius: 20px;
backdrop-filter: blur(10px);
box-shadow: 0 0 30px rgba(0, 255, 255, 0.2);
animation: fadeIn 3s ease-in-out;
}
h1 {
font-size: 3.5rem;
margin-bottom: 20px;
text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
animation: glow 2s ease-in-out infinite alternate;
}
p {
font-size: 1.2rem;
margin-bottom: 30px;
}
.custom-cursor {
position: absolute;
width: 30px;
height: 30px;
border-radius: 50%;
background: radial-gradient(circle, rgba(0, 255, 255, 0.8) 0%, rgba(0, 255, 255, 0) 70%);
pointer-events: none;
z-index: 100;
transform: translate(-50%, -50%);
transition: transform 0.1s ease-out;
mix-blend-mode: screen;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes glow {
from { text-shadow: 0 0 10px rgba(0, 255, 255, 0.5); }
to { text-shadow: 0 0 20px rgba(0, 255, 255, 0.8), 0 0 30px rgba(0, 255, 255, 0.5); }
}
.floating-element {
position: absolute;
border-radius: 50%;
background: rgba(0, 255, 255, 0.1);
box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
animation: float 15s infinite linear;
}
@keyframes float {
0% {
transform: translateY(0) rotate(0deg);
}
100% {
transform: translateY(-100vh) rotate(360deg);
}
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div class="content">
<h1>Willkommen zur Animation</h1>
<p>Beobachten Sie die faszinierenden Effekte, die sich um Sie herum entfalten. Bewegen Sie Ihre Maus, um die Partikel zu beeinflussen.</p>
</div>
<div class="custom-cursor"></div>
<script>
// Canvas Setup
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
// Partikel-System
const particles = [];
const particleCount = 150;
const colors = ['#00ffff', '#00bfff', '#1e90ff', '#0000ff', '#4169e1'];
class Particle {
constructor() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.size = Math.random() * 3 + 1;
this.speedX = Math.random() * 2 - 1;
this.speedY = Math.random() * 2 - 1;
this.color = colors[Math.floor(Math.random() * colors.length)];
this.life = Math.random() * 100 + 50;
this.maxLife = this.life;
this.angle = Math.random() * Math.PI * 2;
this.spin = Math.random() * 0.1 - 0.05;
this.distance = Math.random() * 100 + 50;
}
update() {
this.x += this.speedX;
this.y += this.speedY;
this.life--;
// Partikel folgen der Maus
const dx = mouse.x - this.x;
const dy = mouse.y - this.y;
const distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 100) {
this.x -= dx * 0.02;
this.y -= dy * 0.02;
}
// Partikel drehen sich
this.angle += this.spin;
// Partikel sterben und werden neu geboren
if (this.life <= 0) {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.life = this.maxLife;
}
// Partikel bleiben im Canvas
if (this.x < 0 || this.x > canvas.width) this.speedX *= -1;
if (this.y < 0 || this.y > canvas.height) this.speedY *= -1;
}
draw() {
ctx.beginPath();
ctx.arc(
this.x + Math.cos(this.angle) * this.distance * 0.01,
this.y + Math.sin(this.angle) * this.distance * 0.01,
this.size,
0,
Math.PI * 2
);
const gradient = ctx.createRadialGradient(
this.x, this.y, 0,
this.x, this.y, this.size * 2
);
gradient.addColorStop(0, this.color);
gradient.addColorStop(1, 'transparent');
ctx.fillStyle = gradient;
ctx.fill();
}
}
// Partikel initialisieren
for (let i = 0; i < particleCount; i++) {
particles.push(new Particle());
}
// Mausposition verfolgen
const mouse = {
x: canvas.width / 2,
y: canvas.height / 2
};
window.addEventListener('mousemove', (e) => {
mouse.x = e.clientX;
mouse.y = e.clientY;
// Custom Cursor bewegen
const cursor = document.querySelector('.custom-cursor');
cursor.style.left = e.clientX + 'px';
cursor.style.top = e.clientY + 'px';
});
// Floating Elements erstellen
function createFloatingElements() {
const count = 10;
for (let i = 0; i < count; i++) {
const element = document.createElement('div');
element.classList.add('floating-element');
const size = Math.random() * 100 + 50;
element.style.width = `${size}px`;
element.style.height = `${size}px`;
element.style.left = `${Math.random() * 100}%`;
element.style.top = `${Math.random() * 100 + 100}%`;
element.style.animationDuration = `${Math.random() * 20 + 10}s`;
element.style.animationDelay = `${Math.random() * 5}s`;
document.body.appendChild(element);
}
}
// Animation Loop
function animate() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Hintergrund mit sanftem Farbverlauf
const gradient = ctx.createLinearGradient(0, 0, canvas.width, canvas.height);
gradient.addColorStop(0, '#1a1a2e');
gradient.addColorStop(1, '#16213e');
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Partikel aktualisieren und zeichnen
particles.forEach(particle => {
particle.update();
particle.draw();
});
// Linien zwischen Partikeln zeichnen
for (let i = 0; i < particles.length; i++) {
for (let j = i + 1; j < particles.length; j++) {
const dx = particles[i].x - particles[j].x;
const dy = particles[i].y - particles[j].y;
const distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 100) {
ctx.beginPath();
ctx.strokeStyle = `rgba(0, 255, 255, ${1 - distance / 100})`;
ctx.lineWidth = 0.5;
ctx.moveTo(particles[i].x, particles[i].y);
ctx.lineTo(particles[j].x, particles[j].y);
ctx.stroke();
}
}
}
requestAnimationFrame(animate);
}
// Fenstergröße anpassen
window.addEventListener('resize', () => {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
});
// Initialisierung
createFloatingElements();
animate();
</script>
</body>
</html>
Features dieser Animation:
- Partikelsystem: Hunderte von Partikeln, die sich dynamisch bewegen und auf Mausbewegungen reagieren
- Fließende Formen: Kreise, die sich in verschiedenen Größen und Geschwindigkeiten bewegen
- Farbverläufe: Sanfte Übergänge zwischen Blau- und Türkistönen
- Interaktivität: Die Partikel reagieren auf Mausbewegungen
- Custom Cursor: Ein spezieller Cursor-Effekt
- Floating Elements: Große, langsam schwebende Kreise im Hintergrund
- Verbindungslinien: Partikel sind durch Linien verbunden, wenn sie sich nahe sind
- Responsive Design: Passt sich jeder Bildschirmgröße an
Die Animation startet sofort beim Laden der Seite und schafft ein faszinierendes, fast hypnotisches Erlebnis. Die Kombination aus verschiedenen Animationstechniken macht die Seite besonders dynamisch und ansprechend.