Spaces:
Build error
Build error
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Food Menu Pop-Up</title> | |
| <style> | |
| /* CSS Code */ | |
| body { | |
| font-family: Arial, sans-serif; | |
| margin: 0; | |
| padding: 0; | |
| } | |
| .menu-item { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| padding: 15px; | |
| border: 1px solid #ddd; | |
| border-radius: 8px; | |
| margin: 10px; | |
| } | |
| .menu-item img { | |
| width: 100px; | |
| height: 80px; | |
| object-fit: cover; | |
| cursor: pointer; | |
| } | |
| .menu-item button { | |
| background-color: green; | |
| color: white; | |
| border: none; | |
| padding: 10px; | |
| border-radius: 5px; | |
| cursor: pointer; | |
| } | |
| .menu-item button:hover { | |
| background-color: darkgreen; | |
| } | |
| /* Pop-Up Modal */ | |
| .popup { | |
| position: fixed; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: 100%; | |
| background-color: rgba(0, 0, 0, 0.6); | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| visibility: hidden; | |
| opacity: 0; | |
| transition: visibility 0s, opacity 0.3s ease-in-out; | |
| } | |
| .popup.active { | |
| visibility: visible; | |
| opacity: 1; | |
| } | |
| .popup-content { | |
| background: white; | |
| padding: 20px; | |
| border-radius: 8px; | |
| text-align: center; | |
| width: 50%; | |
| box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); | |
| } | |
| .popup-content img { | |
| width: 100%; | |
| height: auto; | |
| border-radius: 8px; | |
| } | |
| .popup-content h2 { | |
| margin: 15px 0; | |
| } | |
| .popup-content p { | |
| margin: 10px 0; | |
| font-size: 16px; | |
| color: #555; | |
| } | |
| .close-btn { | |
| background: red; | |
| color: white; | |
| border: none; | |
| padding: 10px 20px; | |
| border-radius: 5px; | |
| cursor: pointer; | |
| margin-top: 15px; | |
| } | |
| .close-btn:hover { | |
| background: darkred; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <!-- Food Menu Items --> | |
| <div class="menu-item"> | |
| <div> | |
| <h3>Samosa</h3> | |
| <p>$0.6</p> | |
| <p>Crispy fried pastry filled with spiced potatoes and peas.</p> | |
| </div> | |
| <img src="samosa.jpg" alt="Samosa" class="menu-image" data-name="Samosa" data-price="$0.6" data-description="Crispy fried pastry filled with spiced potatoes and peas. Serves 1. [Energy: 200 kcal, Protein: 5g, Carbohydrates: 25g, Fiber: 3g, Fat: 10g, Sugar: 1g]"> | |
| <button class="add-btn" data-name="Samosa" data-price="$0.6" data-description="Crispy fried pastry filled with spiced potatoes and peas. Serves 1. [Energy: 200 kcal, Protein: 5g, Carbohydrates: 25g, Fiber: 3g, Fat: 10g, Sugar: 1g]">Add</button> | |
| </div> | |
| <!-- Pop-Up Modal --> | |
| <div class="popup" id="popup"> | |
| <div class="popup-content"> | |
| <img id="popup-image" src="" alt="Food Image"> | |
| <h2 id="popup-name"></h2> | |
| <p id="popup-price"></p> | |
| <p id="popup-description"></p> | |
| <button class="close-btn" onclick="closePopup()">Close</button> | |
| </div> | |
| </div> | |
| <script> | |
| // JavaScript Code | |
| const popup = document.getElementById("popup"); | |
| const popupImage = document.getElementById("popup-image"); | |
| const popupName = document.getElementById("popup-name"); | |
| const popupPrice = document.getElementById("popup-price"); | |
| const popupDescription = document.getElementById("popup-description"); | |
| function openPopup(event) { | |
| const target = event.target; | |
| const name = target.dataset.name; | |
| const price = target.dataset.price; | |
| const description = target.dataset.description; | |
| const image = target.src || target.parentNode.querySelector('img').src; | |
| popupName.textContent = name; | |
| popupPrice.textContent = price; | |
| popupDescription.textContent = description; | |
| popupImage.src = image; | |
| popup.classList.add("active"); | |
| } | |
| function closePopup() { | |
| popup.classList.remove("active"); | |
| } | |
| const addButtons = document.querySelectorAll(".add-btn"); | |
| const menuImages = document.querySelectorAll(".menu-image"); | |
| addButtons.forEach(button => button.addEventListener("click", openPopup)); | |
| menuImages.forEach(image => image.addEventListener("click", openPopup)); | |
| </script> | |
| </body> | |
| </html> | |