-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp19.html
66 lines (66 loc) · 1.92 KB
/
temp19.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.container{
display: flex;
justify-content: center;
}
.box{
border: 1px solid black;
margin: 10px;
padding: 10px;
width: 200px;
text-align: center;
}
</style>
</head>
<body>
<div id="root"></div>
<script>
let products = [
{
id: 1,
name: "Laptop",
price: 1000,
quantity: 10,
desc: "Laptop with 8GB RAM and 1TB SSD",
url: "C:/Users/dell/Desktop/photo-1618424181497-157f25b6ddd5.jpg"
},
{
id: 2,
name: "Mobile",
price: 500,
quantity: 20,
desc: "Mobile with 4GB RAM and 64GB Storage",
url:"C:/Users/dell/Desktop/HD-wallpaper-xiaomi-android-mobile-phone-2019.jpg"
},
{
id: 3,
name: "Tablet",
price: 300,
quantity: 15,
desc: "Tablet with 2GB RAM and 32GB Storage",
url :"C:/Users/dell/Desktop/photo-1561154464-82e9adf32764.avif"
},
];
//console.log(products[0]);
let len = products.length;
let str = "<div class = 'container'>";
for (let i = 0; i < len; i++) {
str += `<div class = 'box'>
<img src="${products[i].url}" alt="product" width="200" height="200">
<h2>${products[i].name}</h2>
<p>Price: ${products[i].desc}</p>
<h3>Quantity: ${products[i].price}</h3>
<button>Add to Cart</button>
</div>`;
}
str += '</div>';
root.innerHTML = str;
</script>
</body>
</html>