Responsive Card
Preview
Edit
Download
Run
Download Options
HTML File
Download as .html file
CSS File
Download as .css file
JavaScript File
Download as .js file
Combined HTML
All code in one HTML file
Project ZIP
All files in a ZIP archive
Cancel
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Beautiful Responsive Cards</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <link rel="stylesheet" href="styles.css"> </head> <body> <div class="card-container"> <div class="card"> <div class="tag">Popular</div> <div class="like-btn"> <i class="far fa-heart"></i> </div> <div class="card-img" style="background-color: #e0e0e0;"> <img src="https://images.unsplash.com/photo-1464822759023-fed622ff2c3b?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=600&h=400&q=80" alt="Mountain Retreat" onerror="this.parentElement.style.background='linear-gradient(135deg, #4e54c8, #8f94fb)'"> <div class="unsplash-credit">Photo by Unsplash</div> </div> <div class="card-content"> <h3>Mountain Retreat</h3> <p>Experience the breathtaking views of our premium mountain cabins. Perfect for adventure seekers and nature lovers alike.</p> <div class="card-footer"> <div class="price">$199<span class="price-small">/night</span></div> <button class="btn">Book Now</button> </div> </div> </div> <div class="card"> <div class="tag">Limited</div> <div class="like-btn"> <i class="far fa-heart"></i> </div> <div class="card-img" style="background-color: #e0e0e0;"> <img src="https://images.unsplash.com/photo-1464822759023-fed622ff2c3b?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=600&h=400&q=80" alt="Mountain Retreat" onerror="this.parentElement.style.background='linear-gradient(135deg, #4e54c8, #8f94fb)'"> <div class="unsplash-credit">Photo by Unsplash</div> </div> <div class="card-content"> <h3>Beach Paradise</h3> <p>Relax in luxury with our beachfront villas. White sand, crystal clear water, and all the amenities you need.</p> <div class="card-footer"> <div class="price">$249<span class="price-small">/night</span></div> <button class="btn">Book Now</button> </div> </div> </div> <div class="card"> <div class="tag">New</div> <div class="like-btn"> <i class="far fa-heart"></i> </div> <div class="card-img" style="background-color: #e0e0e0;"> <img src="https://images.unsplash.com/photo-1464822759023-fed622ff2c3b?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=600&h=400&q=80" alt="Mountain Retreat" onerror="this.parentElement.style.background='linear-gradient(135deg, #4e54c8, #8f94fb)'"> <div class="unsplash-credit">Photo by Unsplash</div> </div> <div class="card-content"> <h3>Urban Escape</h3> <p>Modern apartments in the heart of the city. Experience vibrant nightlife, shopping, and cultural attractions.</p> <div class="card-footer"> <div class="price">$179<span class="price-small">/night</span></div> <button class="btn">Book Now</button> </div> </div> </div> </div> <script src="script.js"></script> </body> </html>
CSS
:root { --primary-color: #4e54c8; --secondary-color: #8f94fb; --accent-color: #ff4757; --text-dark: #333; --text-medium: #555; --text-light: #777; --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); --card-shadow: 0 15px 35px rgba(0, 0, 0, 0.1); --card-shadow-hover: 0 20px 40px rgba(0, 0, 0, 0.15); } * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } body { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: var(--bg-gradient); padding: 2rem; line-height: 1.6; } .card-container { display: flex; flex-wrap: wrap; justify-content: center; gap: 2rem; max-width: 1200px; } .card { position: relative; width: 100%; max-width: 350px; height: 480px; background: #fff; border-radius: 1.25rem; overflow: hidden; box-shadow: var(--card-shadow); transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); } .card:hover { transform: translateY(-10px); box-shadow: var(--card-shadow-hover); } .card-img { position: relative; width: 100%; height: 55%; overflow: hidden; } .card-img img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; } .card:hover .card-img img { transform: scale(1.05); } .unsplash-credit { position: absolute; bottom: 10px; right: 10px; background: rgba(0, 0, 0, 0.6); color: white; padding: 0.25rem 0.5rem; border-radius: 3px; font-size: 0.7rem; font-weight: 300; z-index: 2; opacity: 0.8; transition: opacity 0.3s; } .card:hover .unsplash-credit { opacity: 1; } .card-content { position: relative; padding: 1.5rem; height: 45%; display: flex; flex-direction: column; } .card-content h3 { font-size: 1.5rem; margin-bottom: 0.75rem; color: var(--text-dark); font-weight: 700; } .card-content p { color: var(--text-medium); margin-bottom: 1.25rem; font-size: 0.95rem; flex-grow: 1; } .card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; } .price { font-size: 1.5rem; font-weight: 700; color: var(--primary-color); } .price-small { font-size: 1rem; font-weight: 500; color: var(--text-light); } .btn { padding: 0.75rem 1.5rem; background: linear-gradient(45deg, var(--primary-color), var(--secondary-color)); color: white; border: none; border-radius: 50px; cursor: pointer; transition: all 0.3s ease; font-weight: 600; box-shadow: 0 4px 15px rgba(78, 84, 200, 0.3); letter-spacing: 0.5px; } .btn:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(78, 84, 200, 0.4); } .btn:active { transform: translateY(0); } .like-btn { position: absolute; top: 1.25rem; right: 1.25rem; background: white; width: 2.5rem; height: 2.5rem; border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); z-index: 2; transition: all 0.3s ease; } .like-btn:hover { transform: scale(1.15); } .like-btn i { color: var(--accent-color); font-size: 1.2rem; transition: all 0.3s ease; } .like-btn.active i { color: var(--accent-color); transform: scale(1.2); } .tag { position: absolute; top: 1.25rem; left: 1.25rem; background: var(--primary-color); color: white; padding: 0.35rem 1rem; border-radius: 50px; font-size: 0.8rem; font-weight: 600; z-index: 2; text-transform: uppercase; letter-spacing: 0.5px; } @media (max-width: 768px) { .card { max-width: 100%; height: auto; } .card-img { height: 200px; } .card-content { height: auto; padding: 1.25rem; } }
JavaScript
document.addEventListener('DOMContentLoaded', function() { // Enhanced like button functionality const likeButtons = document.querySelectorAll('.like-btn'); likeButtons.forEach(button => { button.addEventListener('click', function(e) { e.stopPropagation(); this.classList.toggle('active'); const icon = this.querySelector('i'); // Add animation class this.classList.add('animate-pulse'); // Change icon if (this.classList.contains('active')) { icon.classList.replace('far', 'fas'); // Small bounce effect this.style.transform = 'scale(1.2)'; setTimeout(() => { this.style.transform = 'scale(1)'; }, 300); } else { icon.classList.replace('fas', 'far'); } // Remove animation class after animation completes setTimeout(() => { this.classList.remove('animate-pulse'); }, 300); }); }); // Enhanced book now button functionality const bookButtons = document.querySelectorAll('.btn'); bookButtons.forEach(button => { button.addEventListener('click', function(e) { e.stopPropagation(); const card = this.closest('.card'); const title = card.querySelector('h3').textContent; const price = card.querySelector('.price').textContent; // Add click effect this.classList.add('clicked'); setTimeout(() => { this.classList.remove('clicked'); }, 300); // Show beautiful alert const alertBox = document.createElement('div'); alertBox.className = 'custom-alert'; alertBox.innerHTML = ` <div class="alert-content"> <i class="fas fa-check-circle"></i> <h4>Added to Cart</h4> <p>${title} - ${price}</p> </div> `; document.body.appendChild(alertBox); setTimeout(() => { alertBox.classList.add('show'); }, 10); setTimeout(() => { alertBox.classList.remove('show'); setTimeout(() => { document.body.removeChild(alertBox); }, 300); }, 3000); }); }); // Card click effect const cards = document.querySelectorAll('.card'); cards.forEach(card => { card.addEventListener('click', function() { this.classList.add('card-clicked'); setTimeout(() => { this.classList.remove('card-clicked'); }, 300); }); }); });
Output Preview
Desktop
Mobile
Fullscreen