3D Team Carousel with Scroll and Swipe Animation using HTML, CSS, and JavaScript
CodewithLord
October 24, 2025
Build a stunning 3D team carousel that lets users scroll, click, or swipe through team members with smooth animations.
đź§ Description
Build a stunning 3D team carousel that lets users scroll, click, or swipe through team members with smooth animations. This project uses only HTML, CSS, and JavaScript — no frameworks — featuring depth effects, transitions, and adaptive mobile controls.
đź’» HTML Code
1<!DOCTYPE html>2<htmllang="en">34<head>5<metacharset="UTF-8">6<title>Team Carousel - by CodewithLord</title>7<linkrel="stylesheet"href="./style.css">89</head>1011<body>12<!DOCTYPE html>13<htmllang="en">14<head>15<metacharset="UTF-8">16<metaname="viewport"content="width=device-width, initial-scale=1.0">17<title>Team Carousel</title>18<linkrel="stylesheet"href="styles.css">19</head>20<body>21<divclass="main-container">22<divclass="carousel-section">23<divclass="carousel-container">24<buttonclass="nav-arrow up">25<imgsrc="assets/top.png"alt="Up">26</button>27<divclass="carousel-track">28<divclass="card"data-index="0">29<imgsrc="https://ik.imagekit.io/gopichakradhar/luffy/o1.jpeg?updatedAt=1754289569411"alt="Team Member 1">30</div>31<divclass="card"data-index="1">32<imgsrc="https://ik.imagekit.io/gopichakradhar/luffy/o2.jpeg?updatedAt=1754289569307"alt="Team Member 2">33</div>34<divclass="card"data-index="2">35<imgsrc="https://ik.imagekit.io/gopichakradhar/luffy/o4.jpeg?updatedAt=1754289569398"alt="Team Member 3">36</div>37<divclass="card"data-index="3">38<imgsrc="https://ik.imagekit.io/gopichakradhar/luffy/o3.jpeg?updatedAt=1754289569422"alt="Team Member 4">39</div>40<divclass="card"data-index="4">41<imgsrc="https://ik.imagekit.io/gopichakradhar/luffy/o5.jpeg?updatedAt=1754289569406"alt="Team Member 5">42</div>43<divclass="card"data-index="5">44<imgsrc="https://ik.imagekit.io/gopichakradhar/luffy/o6.jpeg?updatedAt=1754289569438"alt="Team Member 6">45</div>46</div>47<buttonclass="nav-arrow down">48<imgsrc="https://ik.imagekit.io/gopichakradhar/icons/down.png?updatedAt=1754290523249"alt="Down">49</button>50</div>51</div>5253<divclass="controls-section">54<divclass="nav-controls">55<buttonclass="nav-arrow up">56<imgsrc="https://ik.imagekit.io/gopichakradhar/icons/top.png?updatedAt=1754290522765"alt="Up">57</button>58<buttonclass="nav-arrow down">59<imgsrc="https://ik.imagekit.io/gopichakradhar/icons/down.png?updatedAt=1754290523249"alt="Down">60</button>61</div>6263<divclass="member-info">64<h2class="member-name">Emily Kim</h2>65<pclass="member-role">Founder</p>66</div>6768<divclass="dots">69<divclass="dot active"data-index="0"></div>70<divclass="dot"data-index="1"></div>71<divclass="dot"data-index="2"></div>72<divclass="dot"data-index="3"></div>73<divclass="dot"data-index="4"></div>74<divclass="dot"data-index="5"></div>75</div>76</div>77</div>7879<scriptsrc="scripts.js"></script>80<!-- Floating button with image -->8182</body>83</html>84<scriptsrc="./script.js"></script>8586</body>8788</html>89
The HTML defines two main sections inside .main-container:
carousel-section — holds the rotating stack of cards (each showing a team member image).
controls-section — displays navigation arrows, team member details (name & role), and pagination dots.
Each .card in .carousel-track represents a team member’s image, and the structure ensures only one card is centered at a time.
The buttons (.nav-arrow.up and .nav-arrow.down) and .dot elements are connected to the carousel for navigation control.
The CSS provides a 3D layered illusion using transformations and depth effects:
The .carousel-track uses transform-style: preserve-3d and perspective to give real depth to card transitions.
Cards are positioned using custom classes like .up-1, .down-1, .up-2, .down-2, etc., which move and scale them based on their position relative to the active center card.
The center card is highlighted with a larger scale, brighter colors, and a higher z-index.
Grayscale filters are applied to non-active cards for visual contrast.
The right side contains team member information (.member-info) with subtle animations when changing roles or names.
Dots below the member info act as pagination indicators, and their color and size update dynamically based on which card is active.
The design is fully responsive, with a restructured layout and resized cards on smaller screens.
avaScript handles all the interactivity and carousel movement logic:
Data Setup:
A teamMembers array stores names and roles. The updateCarousel() function updates the UI based on the currently active index.
Card Transitions:
The function removes and reassigns position classes (up-1, down-1, etc.) to cards dynamically, creating smooth 3D rotation effects.
Navigation Controls:
The carousel responds to:
Clicks on up/down arrows
Keyboard arrow keys
Clicking dots
Touch swipe gestures (for mobile)
Card clicks directly on an image
All these inputs call updateCarousel() with the new index value.
Member Info Animation:
The current team member’s name and role fade out and back in as the carousel moves, creating a clean text transition effect.
Scroll Indicator:
A small animated “scroll” badge briefly appears at the bottom-right to hint that the carousel can be scrolled or swiped.
Swipe Detection:
Touch events capture the vertical drag distance (touchstart and touchend), moving the carousel up or down if the swipe passes a threshold.