/* menu card style */ .menu-card background: white; border-radius: 28px; overflow: hidden; transition: all 0.25s ease-in-out; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.02), 0 0 0 1px #f0e7dd; .menu-card:hover transform: translateY(-6px); box-shadow: 0 22px 28px -12px rgba(60, 40, 20, 0.12), 0 0 0 1px #e7d8c8; .card-img width: 100%; height: 180px; object-fit: cover; background: #ddd0be; display: block; transition: transform 0.4s ease; .menu-card:hover .card-img transform: scale(1.02); .card-content padding: 1.3rem 1.3rem 1.5rem; .dish-header display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; .dish-name font-family: 'Playfair Display', serif; font-size: 1.35rem; font-weight: 600; letter-spacing: -0.2px; color: #2f241b; .dish-price font-weight: 700; font-size: 1.3rem; color: #b45f2b; background: #fef5ea; padding: 0.1rem 0.7rem; border-radius: 40px; font-family: monospace; letter-spacing: 0.5px; .dish-desc font-size: 0.88rem; color: #6a5a48; line-height: 1.45; margin: 12px 0 0; border-left: 2px solid #e9daca; padding-left: 12px; .dish-meta margin-top: 12px; display: flex; gap: 12px; font-size: 0.7rem; font-weight: 500; text-transform: uppercase; color: #aa855f; .dish-meta i margin-right: 4px; font-size: 0.7rem; .badge-cat display: inline-block; background: #f3ede5; border-radius: 20px; padding: 2px 10px; font-size: 0.7rem; font-weight: 500; color: #8b5a36;
// Extract unique categories and order (priority: Appetizers, Mains, Pasta, Desserts, Drinks) const categoryOrder = ["Appetizers", "Mains", "Pasta", "Desserts", "Drinks"]; let uniqueCategories = [...new Map(menuData.map(item => [item.category, item.category])).values()]; // sort according to preferred order, then alphabetically for any extra uniqueCategories.sort((a,b) => let indexA = categoryOrder.indexOf(a); let indexB = categoryOrder.indexOf(b); if (indexA !== -1 && indexB !== -1) return indexA - indexB; if (indexA !== -1) return -1; if (indexB !== -1) return 1; return a.localeCompare(b); );
<!-- Menu grid: items rendered dynamically --> <div id="menuGrid" class="menu-grid"></div>
/* responsive touches */ @media (max-width: 680px) .menu-container padding: 1.5rem 1rem; margin: 1rem; .restaurant-name font-size: 2.2rem; .filter-btn padding: 0.4rem 1rem; font-size: 0.8rem; .menu-grid gap: 1.3rem; </style> </head> <body> <div class="menu-container"> <div class="hero"> <h1 class="restaurant-name">LE BISTRO</h1> <div class="restaurant-tagline">✨ Artisanal Flavors · Rustic Elegance ✨</div> <div class="menu-subhead"> <i class="fas fa-utensils"></i> Seasonal ingredients · Handcrafted dishes · Soulful dining </div> </div> restaurant menu html css codepen
if (filteredItems.length === 0) menuGrid.innerHTML = `<div class="no-results"><i class="fas fa-utensils"></i> No dishes found in this category.<br>Try another delicious section ✨</div>`; return;
/* custom scrollbar */ ::-webkit-scrollbar width: 6px; ::-webkit-scrollbar-track background: #e9e0d3; ::-webkit-scrollbar-thumb background: #b87c4f; border-radius: 8px;
<script> // ---------- RESTAURANT MENU DATA (realistic, diverse) ---------- const menuData = [ // Appetizers id: 1, name: "Burrata Caprese", price: "$16", category: "Appetizers", desc: "Creamy burrata, heirloom tomatoes, aged balsamic, basil oil & grilled sourdough.", icon: "fa-seedling", img: "https://images.unsplash.com/photo-1601050690597-df0568f70950?w=500&auto=format", dietary: "veg" , id: 2, name: "Truffle Arancini", price: "$14", category: "Appetizers", desc: "Crispy risotto balls, wild mushroom ragu, truffle aioli & parmesan.", icon: "fa-mushroom", img: "https://images.unsplash.com/photo-1546069901-ba9599a7e63c?w=500&auto=format", dietary: "veg" , id: 3, name: "Lamb Keftedes", price: "$18", category: "Appetizers", desc: "Greek-style lamb meatballs, tzatziki, pickled red onion & fresh mint.", icon: "fa-drumstick-bite", img: "https://images.unsplash.com/photo-1559847844-5315695dadae?w=500&auto=format", dietary: "meat" , // Main Courses id: 4, name: "Seared Sea Bass", price: "$34", category: "Mains", desc: "Mediterranean sea bass, saffron orzo, citrus beurre blanc, fennel slaw.", icon: "fa-fish", img: "https://images.unsplash.com/photo-1519708227418-c8fd9a32b7a2?w=500&auto=format", dietary: "seafood" , id: 5, name: "Porcini Risotto", price: "$27", category: "Mains", desc: "Carnaroli rice, wild porcini, parmesan cream, truffle oil & crispy sage.", icon: "fa-bowl-food", img: "https://images.unsplash.com/photo-1476124369491-e7addf5db371?w=500&auto=format", dietary: "veg" , id: 6, name: "Braised Short Rib", price: "$39", category: "Mains", desc: "Red wine braised beef, creamy parsnip purée, roasted carrots & gremolata.", icon: "fa-utensils", img: "https://images.unsplash.com/photo-1600891964092-4316c288032e?w=500&auto=format", dietary: "meat" , id: 7, name: "Herb Chicken Paillard", price: "$28", category: "Mains", desc: "Free-range chicken, lemon-herb marinade, arugula, shaved fennel & aged parmesan.", icon: "fa-egg", img: "https://images.unsplash.com/photo-1604909052743-94ab495dffb9?w=500&auto=format", dietary: "meat" , // Pasta & Risotto section (additional) id: 8, name: "Lobster Ravioli", price: "$36", category: "Pasta", desc: "House-made ravioli, maine lobster, saffron cream, chervil & toasted breadcrumbs.", icon: "fa-lobster", img: "https://images.unsplash.com/photo-1563379926898-05f4575a45e8?w=500&auto=format", dietary: "seafood" , id: 9, name: "Cacio e Pepe", price: "$22", category: "Pasta", desc: "Roman classic, tonnarelli pasta, pecorino romano, toasted black pepper & butter.", icon: "fa-cheese", img: "https://images.unsplash.com/photo-1551183053-bf91a1d81141?w=500&auto=format", dietary: "veg" , // Desserts id: 10, name: "Salted Caramel Tart", price: "$12", category: "Desserts", desc: "Dark chocolate shell, salted caramel ganache, vanilla bean chantilly & fleur de sel.", icon: "fa-cake-candles", img: "https://images.unsplash.com/photo-1587314168485-3236d6710814?w=500&auto=format", dietary: "veg" , id: 11, name: "Lemon Ricotta Cake", price: "$11", category: "Desserts", desc: "Whipped ricotta, lemon curd, wild berries & honeycomb crumble.", icon: "fa-lemon", img: "https://images.unsplash.com/photo-1571115177098-24ec42ed204d?w=500&auto=format", dietary: "veg" , id: 12, name: "Affogato al Caffè", price: "$9", category: "Desserts", desc: "Vanilla gelato, espresso shot, amaretti cookie crumble & dark chocolate shavings.", icon: "fa-mug-hot", img: "https://images.unsplash.com/photo-1579954115545-a95591f28bfc?w=500&auto=format", dietary: "veg" , // Drinks / Cocktails id: 13, name: "Elderflower Spritz", price: "$13", category: "Drinks", desc: "Elderflower liqueur, prosecco, soda, fresh mint & cucumber ribbon.", icon: "fa-wine-glass", img: "https://images.unsplash.com/photo-1560512823-829485b8bf24?w=500&auto=format", dietary: "veg" , id: 14, name: "Smoked Old Fashioned", price: "$16", category: "Drinks", desc: "Bourbon, maple bitters, smoked with cherrywood & orange zest.", icon: "fa-whiskey-glass", img: "https://images.unsplash.com/photo-1470337458703-46ad1756a187?w=500&auto=format", dietary: "veg" , id: 15, name: "Rosemary Paloma", price: "$14", category: "Drinks", desc: "Tequila, grapefruit, rosemary syrup, lime & sparkling water.", icon: "fa-cocktail", img: "https://images.unsplash.com/photo-1551024709-8f23befc6f87?w=500&auto=format", dietary: "veg" ]; /* menu card style */
<div class="footer-note"> <span><i class="fas fa-leaf"></i> Locally sourced</span> <span><i class="fas fa-wine-bottle"></i> Wine pairing available</span> <span><i class="fas fa-clock"></i> Tue–Sun 5PM – 11PM</span> </div> </div>
// attach event listeners document.querySelectorAll('.filter-btn').forEach(btn => btn.addEventListener('click', (e) => const filterValue = btn.getAttribute('data-filter'); if (filterValue === 'all') activeCategory = null; else activeCategory = filterValue; renderFilters(); // re-render to update active class renderMenuItems(); // render filtered menu ); );
/* header & hero section */ .hero text-align: center; margin-bottom: 3rem; border-bottom: 2px dashed #e6d5c0; padding-bottom: 2rem; .restaurant-name font-family: 'Playfair Display', serif; font-size: 3.2rem; font-weight: 600; letter-spacing: -0.5px; color: #3e2a1f; margin-bottom: 0.4rem; .restaurant-tagline font-size: 1rem; font-weight: 400; color: #8b6b4d; letter-spacing: 2px; text-transform: uppercase; background: #f3ede5; display: inline-block; padding: 0.3rem 1.2rem; border-radius: 40px; backdrop-filter: blur(2px); .menu-subhead margin-top: 1rem; font-size: 0.95rem; max-width: 580px; margin-left: auto; margin-right: auto; color: #5e4b34; font-weight: 400; transition: all 0.25s ease-in-out
/* no results message */ .no-results grid-column: 1 / -1; text-align: center; padding: 3rem; background: #faf6f0; border-radius: 48px; font-size: 1rem; color: #b18762;
init(); </script> </body> </html>
// DOM elements const filterContainer = document.getElementById("filterTabs"); const menuGrid = document.getElementById("menuGrid");
body background: #f9f6ef; font-family: 'Inter', sans-serif; color: #2c2418; line-height: 1.4; scroll-behavior: smooth;
// simple XSS prevention function escapeHtml(str) return str.replace(/[&<>]/g, function(m) if (m === '&') return '&'; if (m === '<') return '<'; if (m === '>') return '>'; return m; ).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, function(c) return c; );