Introduction
In this tutorial, we’ll create an ultra-premium, 3D gladiator-themed product showcase featuring animated product cards, dynamic hover effects, click interactions, and a glowing particle effect that brings each item to life. Designed for immersive user experiences, this showcase combines 3D transformations, glowing animations, and pulsating highlights to give each product a unique and interactive feel. This design is inspired by Gladiators Battle, an interactive game where players experience the thrill of ancient battles and strategy.
Follow along to create your own interactive product showcase and learn how to use HTML, CSS, and JavaScript for stunning visuals and dynamic animations.
Step 1: Setting Up the HTML Structure
Each product card represents a gladiator-themed item, like a shield or sword, with interactive elements such as badges, icons, and stats.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D Gladiator Product Showcase</title>
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
</head>
<body>
<div class="product-showcase">
<!-- Gladiator Shield Card -->
<div class="product-card" id="card1">
<div class="badge">New</div>
<div class="product-image">
<img src="gladiator_shield.png" alt="Gladiator Shield">
</div>
<h3>Gladiator Shield</h3>
<p class="product-description">A robust shield crafted for the finest gladiators. Offers high defense and durability.</p>
<div class="stats">
<div class="stat-bar">
<span>Defense</span>
<div class="progress">
<div class="progress-bar" style="width: 85%;"></div>
</div>
</div>
<div class="stat-bar">
<span>Durability</span>
<div class="progress">
<div class="progress-bar" style="width: 90%;"></div>
</div>
</div>
</div>
<div class="icons">
<i class="fas fa-shield-alt"></i>
<i class="fas fa-star"></i>
<i class="fas fa-heart"></i>
</div>
</div>
<!-- Add similar structure for other items like Sword and Battle Card -->
</div>
<script src="script.js"></script>
</body>
</html>
Key HTML Elements
Badge: Labels each item with statuses like "New" or "Popular."
Product Image: Displays the item with a glowing effect and 3D depth.
Stats: Uses progress bars to display item attributes like defense or attack.
Icons: Interactive icons at the bottom of each card provide quick access to favorite actions.
Step 2: Designing with CSS
Basic Styles and Background
The background uses a radial gradient to create a dramatic look, while each product card is styled with gradients, shadows, and smooth transitions.
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
background: radial-gradient(circle at center, #1b1b2f, #090909);
font-family: Arial, sans-serif;
overflow: hidden;
color: #fff;
}
.product-showcase {
display: flex;
gap: 40px;
perspective: 1200px;
}
Product Card Styles
Each card is designed with a 3D look and includes hover effects for interactivity. The :hover effect provides a subtle rotation and glow, enhancing the premium feel.
.product-card {
position: relative;
width: 270px;
height: 420px;
padding: 25px;
background: linear-gradient(145deg, #2a2a2a, #3c3c3c);
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 20px rgba(255, 215, 0, 0.5);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
transform-style: preserve-3d;
transition: transform 0.5s, box-shadow 0.5s, background 0.5s;
cursor: pointer;
overflow: hidden;
}
.product-card:hover {
transform: scale(1.1) rotateY(10deg);
box-shadow: 0 30px 60px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 255, 0, 0.7);
}
Stats and Progress Bars
We use progress bars to display attributes such as defense and durability, which add a unique visual element to the showcase.
.stats {
width: 100%;
margin-top: 15px;
}
.stat-bar {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
color: #ffd700;
font-size: 14px;
font-weight: bold;
}
.progress {
width: 60%;
height: 8px;
background: rgba(255, 255, 255, 0.2);
border-radius: 5px;
}
.progress-bar {
height: 100%;
background: linear-gradient(90deg, #ffcc00, #f9844a);
}
Adding Particle Effects
Adding particles that move and change color enhances the immersive feel. These particles can pulsate to give a glowing effect.
.particle {
position: absolute;
width: 4px;
height: 4px;
border-radius: 50%;
background: rgba(255, 215, 0, 0.9);
box-shadow: 0 0 10px rgba(255, 215, 0, 0.5), 0 0 20px rgba(255, 255, 0, 0.3);
animation: particleAnimation 3s ease-in-out infinite, particleMove 4s linear infinite;
}
Step 3: Adding JavaScript Interactivity
The JavaScript manages hover animations, click events, and the glowing particle effect.
Adding Hover and Click Animations
We animate the card rotation and scaling on mouse movement and toggle zoom with a click.
const cards = document.querySelectorAll('.product-card');
cards.forEach((card) => {
let isClicked = false;
card.addEventListener('mousemove', (e) => {
if (!isClicked) {
const { width, height } = card.getBoundingClientRect();
const offsetX = e.clientX - card.offsetLeft - width / 2;
const offsetY = e.clientY - card.offsetTop - height / 2;
const rotationX = (offsetY / height) * -25;
const rotationY = (offsetX / width) * 25;
card.style.transform = `rotateY(${rotationY}deg) rotateX(${rotationX}deg) scale(1.05)`;
}
});
card.addEventListener('mouseleave', () => {
if (!isClicked) {
card.style.transform = 'rotateY(0deg) rotateX(0deg) scale(1)';
}
});
card.addEventListener('click', () => {
isClicked = !isClicked;
card.style.transform = isClicked
? 'scale(1.2) rotateY(0deg) rotateX(0deg)'
: 'rotateY(0deg) rotateX(0deg) scale(1)';
});
});
Adding Glowing Particles
To enhance the atmosphere, we create particles that move randomly around each product card.
function addParticleEffect() {
const particle = document.createElement('div');
particle.classList.add('particle');
particle.style.left = `${Math.random() * 100}%`;
particle.style.top = `${Math.random() * 100}%`;
particle.style.animationDuration = `${2 + Math.random() * 3}s`;
document.body.appendChild(particle);
setTimeout(() => particle.remove(), 5000);
}
setInterval(() => {
cards.forEach(() => addParticleEffect());
}, 1000);
Conclusion
Building a 3D gladiator-themed product showcase with dynamic animations and particle effects creates an engaging, interactive experience that can captivate users. By combining CSS for visual styling and JavaScript for interactivity, we’ve created a high-quality, immersive component ideal for product displays or gaming-related sites. Inspired by Gladiators Battle, this showcase highlights the power of combining modern web design with historical themes.
🔹 Discover More:
Explore Gladiators Battle: Dive into a world of ancient warriors and strategic gameplay at https://gladiatorsbattle.com.
GitHub: View more projects at https://github.com/HanGPIErr.
LinkedIn: Connect for updates on projects at https://www.linkedin.com/in/pierre-romain-lopez/.
Twitter: Follow for design and development insights at https://x.com/GladiatorsBT.
Stay tuned for more tutorials on creating engaging, interactive components!
Top comments (0)