Spaces:
Build error
Build error
File size: 4,924 Bytes
93316a5 9e86f1c 7b771cf 9e86f1c 93316a5 9e86f1c 93316a5 9e86f1c 93316a5 7b771cf 9e86f1c 7b771cf 9e86f1c 93316a5 9e86f1c 7b771cf 9e86f1c 93316a5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | <!DOCTYPE html>
<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>
|