Claro! Vou criar uma página única, super estilosa e moderna, com um botão que dispara uma explosão de confetti ultra detalhada, com partículas coloridas, efeitos de física, sombreamento, e uma animação suave. Tudo em um único arquivo HTML com CSS e JS embutidos.
html Copy code
<!DOCTYPE html>
<html lang="pt-BR" >
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Botão Confetti ÉPICO 🎉</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@700&display=swap');
/* Reset */
* {
margin: 0; padding: 0; box-sizing: border-box;
}
body, html {
height: 100%;
background: linear-gradient(135deg, #1e3c72, #2a5298);
display: flex;
justify-content: center;
align-items: center;
font-family: 'Poppins', sans-serif;
overflow: hidden;
user-select: none;
}
.container {
text-align: center;
position: relative;
z-index: 10;
}
h1 {
color: #fff;
font-size: 3rem;
margin-bottom: 1rem;
text-shadow: 0 0 10px rgba(255 255 255 / 0.7);
}
button.confetti-btn {
background: linear-gradient(45deg, #ff416c, #ff4b2b);
border: none;
padding: 1.5rem 3rem;
font-size: 1.8rem;
font-weight: 700;
color: white;
border-radius: 50px;
cursor: pointer;
box-shadow:
0 0 10px #ff416c,
0 0 20px #ff4b2b,
0 0 30px #ff416c,
0 0 40px #ff4b2b;
transition: transform 0.2s ease, box-shadow 0.3s ease;
position: relative;
overflow: hidden;
user-select: none;
}
button.confetti-btn:hover {
transform: scale(1.1);
box-shadow:
0 0 20px #ff416c,
0 0 40px #ff4b2b,
0 0 60px #ff416c,
0 0 80px #ff4b2b;
}
button.confetti-btn:active {
transform: scale(0.95);
box-shadow: 0 0 5px #ff4b2b;
}
/* Confetti canvas */
#confetti-canvas {
position: fixed;
pointer-events: none;
top: 0; left: 0;
width: 100vw;
height: 100vh;
z-index: 9999;
mix-blend-mode: screen;
}
/* Sparkle effect */
.sparkle {
position: absolute;
border-radius: 50%;
background: radial-gradient(circle, #fff 0%, transparent 70%);
pointer-events: none;
animation: sparkle-flicker 1.2s infinite;
filter: drop-shadow(0 0 4px #fff);
opacity: 0.8;
}
@keyframes sparkle-flicker {
0%, 100% { opacity: 0.8; transform: scale(1); }
50% { opacity: 0.3; transform: scale(1.3); }
}
</style>
</head>
<body>
<div class="container">
<h1>Botão Confetti ÉPICO 🎉</h1>
<button class="confetti-btn" id="confettiBtn">Clique aqui e EXPLODA 🎊</button>
</div>
<canvas id="confetti-canvas"></canvas>
<script>
(() => {
const canvas = document.getElementById('confetti-canvas');
const ctx = canvas.getContext('2d');
let W, H;
function resize() {
W = window.innerWidth;
H = window.innerHeight;
canvas.width = W * devicePixelRatio;
canvas.height = H * devicePixelRatio;
canvas.style.width = W + 'px';
canvas.style.height = H + 'px';
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.scale(devicePixelRatio, devicePixelRatio);
}
resize();
window.addEventListener('resize', resize);
// Confetti particle class
class ConfettiParticle {
constructor(x, y, color) {
this.x = x;
this.y = y;
this.size = Math.random() * 8 + 6;
this.color = color;
this.gravity = 0.3 + Math.random() * 0.2;
this.rotation = Math.random() * 360;
this.rotationSpeed = (Math.random() - 0.5) * 20;
this.speedX = (Math.random() - 0.5) * 10;
this.speedY = (Math.random() - 1.5) * 10;
this.opacity = 1;
this.drift = (Math.random() - 0.5) * 0.5;
this.shape = Math.random() > 0.5 ? 'rect' : 'circle';
this.tilt = Math.random() * 15;
this.tiltSpeed = (Math.random() - 0.5) * 0.5;
this.life = 0;
this.maxLife = 120 + Math.random() * 60;
}
update() {
this.speedY += this.gravity * 0.1;
this.x += this.speedX + this.drift;
this.y += this.speedY;
this.rotation += this.rotationSpeed;
this.tilt += this.tiltSpeed;
this.opacity -= 1 / this.maxLife;
this.life++;
}
draw(ctx) {
ctx.save();
ctx.translate(this.x, this.y);
ctx.rotate(this.rotation * Math.PI / 180);
ctx.globalAlpha = Math.max(this.opacity, 0);
if (this.shape === 'rect') {
ctx.fillStyle = this.color;
ctx.shadowColor = this.color;
ctx.shadowBlur = 8;
ctx.fillRect(-this.size / 2, -this.size / 2 + Math.sin(this.tilt) * 5, this.size, this.size / 2);
} else {
// circle with glow
let gradient = ctx.createRadialGradient(0, 0, this.size / 4, 0, 0, this.size / 1.5);
gradient.addColorStop(0, this.color);
gradient.addColorStop(1, 'transparent');
ctx.fillStyle = gradient;
ctx.shadowColor = this.color;
ctx.shadowBlur = 10;
ctx.beginPath();
ctx.ellipse(0, Math.sin(this.tilt) * 3, this.size / 2, this.size / 3, 0, 0, 2 * Math.PI);
ctx.fill();
}
ctx.restore();
}
isDead() {
return this.opacity <= 0 || this.y > H + 20;
}
}
// Colors palette
const colors = [
'#ff4b2b', '#ff416c', '#1e90ff', '#00ffcc', '#ffdd00', '#ff6f91', '#845ec2', '#00c9a7', '#ffc75f'
];
let confettiParticles = [];
function createConfetti(x, y, count = 150) {
for (let i = 0; i < count; i++) {
const color = colors[Math.floor(Math.random() * colors.length)];
confettiParticles.push(new ConfettiParticle(x, y, color));
}
}
function animate() {
ctx.clearRect(0, 0, W, H);
confettiParticles.forEach((p, i) => {
p.update();
p.draw(ctx);
if (p.isDead()) {
confettiParticles.splice(i, 1);
}
});
requestAnimationFrame(animate);
}
animate();
// Sparkle effect on button
const btn = document.getElementById('confettiBtn');
btn.addEventListener('click', (e) => {
const rect = btn.getBoundingClientRect();
const x = rect.left + rect.width / 2;
const y = rect.top + rect.height / 2;
createConfetti(x, y);
// Create sparkles around button
for (let i = 0; i < 20; i++) {
createSparkle(btn);
}
});
function createSparkle(parent) {
const sparkle = document.createElement('div');
sparkle.classList.add('sparkle');
const size = Math.random() * 6 + 4;
sparkle.style.width = size + 'px';
sparkle.style.height = size + 'px';
// Position sparkle randomly around button
const rect = parent.getBoundingClientRect();
sparkle.style.left = (rect.left + Math.random() * rect.width) + 'px';
sparkle.style.top = (rect.top + Math.random() * rect.height) + 'px';
document.body.appendChild(sparkle);
// Animate sparkle flicker and fade out
sparkle.animate([
{ opacity: 1, transform: 'scale(1)' },
{ opacity: 0, transform: 'scale(2)' }
], {
duration: 800 + Math.random() * 400,
easing: 'ease-out',
fill: 'forwards'
});
setTimeout(() => {
sparkle.remove();
}, 1200);
}
})();
</script>
</body>
</html>
Basta abrir esse arquivo no navegador e clicar no botão para ver a explosão de confetti mais braba que você já viu! Se quiser, posso ajudar a personalizar ainda mais. Quer?