DevPlatform
Home
Components
Search
Submit
Earn
Login
Sign Up Free
Animated Card - Preview | DevPlatform
DevPlatform
Categories
Accordion
Animation
Box Shadow
Button
Card
Footer
Form
Gallery
Hero Section
Inputs
Loader
Marquee
Modal
Modules
Navbar
Progress Bar
Radio Buttons
Search-Bar
Sections
Slider
Tab
Timeline
Toggle
Animated Card
rohit
Feb 13, 2026
12
0
Share
Live Preview
Refresh
Live Editor
HTML
CSS
JS
HTML
CSS
JavaScript
1
<div class="card" id="card"> <h2 class="title">confuse</h2> <div class="eyes"> <div class="eye"> <div class="pupil"></div> </div> <div class="eye"> <div class="pupil"></div> </div> </div> <div class="nose">O</div> </div>
1
body { margin: 0; height: 100vh; background: #f39c12; display: flex; justify-content: center; align-items: center; font-family: Arial, sans-serif; transition: background 0.3s ease; } .card { width: 260px; height: 300px; background: #f1c40f; border-radius: 20px; text-align: center; position: relative; padding-top: 40px; transition: background 0.3s ease, transform 0.2s ease; box-shadow: 0 20px 40px rgba(0,0,0,0.2); } .title { color: rgba(255,255,255,0.6); font-weight: bold; letter-spacing: 2px; } .eyes { display: flex; justify-content: center; gap: 30px; margin-top: 40px; } .eye { width: 70px; height: 70px; background: white; border-radius: 50%; display: flex; justify-content: center; align-items: center; box-shadow: 0 8px 15px rgba(0,0,0,0.2); position: relative; } .pupil { width: 20px; height: 20px; background: black; border-radius: 50%; position: absolute; transition: transform 0.1s linear; } .nose { margin-top: 40px; font-size: 40px; font-weight: bold; color: black; text-shadow: 0 5px 10px rgba(255,0,0,0.4); transition: transform 0.2s ease; }
1
const pupils = document.querySelectorAll(".pupil"); const card = document.getElementById("card"); document.addEventListener("mousemove", (e) => { const mouseX = e.clientX; const mouseY = e.clientY; pupils.forEach(pupil => { const rect = pupil.parentElement.getBoundingClientRect(); const eyeX = rect.left + rect.width / 2; const eyeY = rect.top + rect.height / 2; const angle = Math.atan2(mouseY - eyeY, mouseX - eyeX); const moveX = Math.cos(angle) * 15; const moveY = Math.sin(angle) * 15; pupil.style.transform = `translate(${moveX}px, ${moveY}px)`; }); // Dynamic color change const hue = (mouseX / window.innerWidth) * 360; card.style.background = `hsl(${hue}, 80%, 60%)`; });
Comments
0
Want to comment?
Please
login
or
sign up
to post comments.
No comments yet
Be the first to comment on this component!
Comments 0
Want to comment?
Please login or sign up to post comments.
No comments yet
Be the first to comment on this component!