-
Notifications
You must be signed in to change notification settings - Fork 618
/
EcoFriendlyShop.html
384 lines (330 loc) · 11.5 KB
/
EcoFriendlyShop.html
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Eco-Friendly Shop</title>
<!-- Font and Icon Links -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
<!-- Custom Styles -->
<style>
body {
font-family: 'Roboto', sans-serif;
background-color: #f3f4f6;
color: #333;
padding: 0;
margin: 0;
}
.navbar {
background-color: #28a745;
padding: 10px 20px;
}
.navbar-brand {
font-size: 1.5rem;
color: #fff;
font-weight: bold;
}
.nav-link {
color: white;
font-size: 1.2rem;
margin-right: 20px;
}
.nav-link:hover {
color: #f1f1f1;
}
.shop-title {
text-align: center;
margin-top: 20px;
font-size: 2.5rem;
font-weight: bold;
color: #333;
}
.product-container {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 30px;
margin: 30px 20px;
}
.product-card {
background-color: white;
border-radius: 10px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
padding: 20px;
text-align: center;
width: 250px;
transition: transform 0.2s ease-in-out;
}
.product-card:hover {
transform: scale(1.05);
}
.product-card img {
max-width: 100%;
height: auto;
margin-bottom: 15px;
}
.product-card h3 {
font-size: 1.4rem;
margin: 10px 0;
}
.product-card p {
font-size: 1.2rem;
color: #28a745;
margin-bottom: 15px;
}
.product-card button {
background-color: #28a745;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
.product-card button:hover {
background-color: #218838;
}
.cart-section {
text-align: center;
margin: 50px 0;
}
.cart-section h2 {
font-size: 2rem;
}
.cart-items {
list-style-type: none;
padding: 0;
}
.cart-items li {
margin: 10px 0;
font-size: 1.2rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.cart-controls {
display: flex;
align-items: center;
gap: 10px;
}
.cart-controls button {
background-color: #28a745;
color: white;
padding: 5px 10px;
border: none;
border-radius: 3px;
cursor: pointer;
}
.cart-controls button:hover {
background-color: #218838;
}
.faq-section {
margin: 50px auto;
text-align: center;
max-width: 800px;
}
.faq-title {
font-size: 2rem;
font-weight: bold;
margin-bottom: 20px;
}
.faq-item {
margin-bottom: 15px;
}
.faq-item h4 {
font-size: 1.5rem;
color: #333;
cursor: pointer;
transition: color 0.2s ease-in-out;
}
.faq-item h4:hover {
color: #28a745;
}
.faq-answer {
font-size: 1.2rem;
color: #555;
display: none;
margin-top: 10px;
}
.why-eco-section {
background-color: #e9f7ef;
padding: 40px 20px;
text-align: center;
margin-bottom: 50px;
}
.why-eco-title {
font-size: 2rem;
margin-bottom: 20px;
font-weight: bold;
}
.why-eco-description {
font-size: 1.2rem;
color: #333;
}
footer {
background-color: #28a745;
color: white;
padding: 20px 0;
text-align: center;
}
@media (max-width: 768px) {
.product-container {
flex-direction: column;
align-items: center;
}
.product-card {
width: 100%;
max-width: 300px;
}
.nav-link {
font-size: 1rem;
}
}
</style>
</head>
<body>
<!-- Navigation Bar -->
<nav class="navbar navbar-expand-lg navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="#">Eco-Friendly Shop 🛍️</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#shop">Shop</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#cart">Cart</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#faq">FAQ</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Shop Section -->
<div class="shop-title">Eco-Friendly Products</div>
<div class="product-container" id="shop">
<div class="product-card">
<img src="https://www.ecomena.org/wp-content/uploads/2018/07/reusuable-shopping-bags.jpg" alt="Reusable Bag">
<h3>Reusable Bag</h3>
<p>Price: $10.00</p>
<button onclick="addToCart('Reusable Bag', 10)">Add to Cart</button>
</div>
<div class="product-card">
<img src="https://rukminim2.flixcart.com/image/750/900/l0tweq80/bottle/q/j/g/1000-elina-plastic-water-bottle-for-fridge-home-office-gym-and-original-imagcj4a9jkppzkw.jpeg?q=20&crop=false" alt="Eco Water Bottle">
<h3>Eco Water Bottle</h3>
<p>Price: $15.00</p>
<button onclick="addToCart('Eco Water Bottle', 15)">Add to Cart</button>
</div>
<div class="product-card">
<img src="https://www.theimpatientgardener.com/wp-content/uploads/2020/01/seeds-8443.jpg" alt="Plantable Seeds">
<h3>Plantable Seeds</h3>
<p>Price: $5.00</p>
<button onclick="addToCart('Plantable Seeds', 5)">Add to Cart</button>
</div>
</div>
<!-- Cart Section -->
<section class="cart-section" id="cart">
<h2>Your Cart</h2>
<ul class="cart-items"></ul>
<p><strong>Total Price: $<span id="total-price">0</span></strong></p>
</section>
<!-- Why Eco-Friendly Products Section -->
<section class="why-eco-section">
<h2 class="why-eco-title">Why Use Eco-Friendly Products?</h2>
<p class="why-eco-description">
Choosing eco-friendly products helps to reduce your carbon footprint, conserve natural resources, and protect the environment. By using sustainable and reusable items like bags and water bottles, you're contributing to a healthier planet for future generations.
</p>
</section>
<!-- FAQ Section -->
<section class="faq-section" id="faq">
<h2 class="faq-title">Frequently Asked Questions</h2>
<div class="faq-item">
<h4 onclick="toggleFAQ(this)">What is the purpose of eco-friendly products?</h4>
<p class="faq-answer">
Eco-friendly products are designed to reduce waste, conserve resources, and minimize environmental impact. They help promote sustainability and are often reusable or made from sustainable materials.
</p>
</div>
<div class="faq-item">
<h4 onclick="toggleFAQ(this)">How are the profits used?</h4>
<p class="faq-answer">
The profits from our eco-friendly shop go towards supporting environmental conservation efforts, including donations to green organizations and funding for ecological campaigns.
</p>
</div>
<div class="faq-item">
<h4 onclick="toggleFAQ(this)">Can I return or exchange a product?</h4>
<p class="faq-answer">
Yes, we offer returns or exchanges on products within 30 days of purchase, as long as they are in unused condition. Please contact our support team for further assistance.
</p>
</div>
</section>
<!-- Footer -->
<footer>
<p>© 2024 Eco-Friendly Shop. All rights reserved.</p>
</footer>
<!-- Script for adding to cart and FAQ toggle -->
<script>
let cartItems = [];
let totalPrice = 0;
function addToCart(item, price) {
const cartItem = cartItems.find(i => i.name === item);
if (cartItem) {
cartItem.quantity++;
} else {
cartItems.push({ name: item, price, quantity: 1 });
}
updateCart();
}
function updateCart() {
document.querySelector('.cart-items').innerHTML = cartItems.map((cartItem, index) => `
<li>
${cartItem.name} - $${cartItem.price} x ${cartItem.quantity}
<span class="cart-controls">
<button onclick="decreaseQuantity(${index})">-</button>
<button onclick="increaseQuantity(${index})">+</button>
<button onclick="removeFromCart(${index})">Remove</button>
</span>
</li>
`).join('');
calculateTotal();
}
function increaseQuantity(index) {
cartItems[index].quantity++;
updateCart();
}
function decreaseQuantity(index) {
if (cartItems[index].quantity > 1) {
cartItems[index].quantity--;
} else {
cartItems.splice(index, 1);
}
updateCart();
}
function removeFromCart(index) {
cartItems.splice(index, 1);
updateCart();
}
function calculateTotal() {
totalPrice = cartItems.reduce((total, item) => total + item.price * item.quantity, 0);
document.getElementById('total-price').innerText = totalPrice;
}
function toggleFAQ(element) {
const answer = element.nextElementSibling;
if (answer.style.display === 'block') {
answer.style.display = 'none';
} else {
answer.style.display = 'block';
}
}
</script>
</body>
</html>