-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart.html
102 lines (87 loc) · 2.68 KB
/
cart.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
text-align: center;
/* background-color: rgb(241, 175, 184); */
}
#container{
display: grid;
grid-template-columns: repeat(4,1fr);
grid-template-rows: auto;
gap: 20px;
margin-top: 2%;
}
#container>div{
box-shadow: rgba(0, 0, 0, 0.07) 0px 1px 1px, rgba(0, 0, 0, 0.07) 0px 2px 2px, rgba(0, 0, 0, 0.07) 0px 4px 4px, rgba(0, 0, 0, 0.07) 0px 8px 8px, rgba(0, 0, 0, 0.07) 0px 16px 16px;
text-align: center;
}
#container>div>img{
width:80%;
}
#container>div>img:hover{
width: 90%;
}
button{
width: 150px;
height: 25px;
background-color: aquamarine;
border-radius: 20px;
}
input{
width: 400px;
height: 20px;
background-color: rgb(214, 214, 214);
}
/* Medium screens */
@media all and (min-width: 451px) and (max-width: 750px) {
#container{
grid-template-columns: repeat(2,1fr);
}
}
/* Small screens */
@media all and (min-width: 100px) and (max-width: 450px) {
#container{
grid-template-columns: repeat(1,1fr);
}
}
</style>
</head>
<body>
<h3> <a style="text-decoration: none;" href="./product.html">Home Page</a></h3>
<div id="container"></div>
</body>
</html>
<script>
let items = JSON.parse(localStorage.getItem("cartproduct"));
console.log(items)
displayTable(items);
function displayTable(array){
console.log(array)
document.querySelector("#container").innerHTML="";
array.forEach((element) => {
let div=document.createElement("div")
let img=document.createElement("img")
img.setAttribute("src",element.image_link)
let name=document.createElement("h4")
name.innerText=element.name;
let id=document.createElement("h3")
id.innerText=element.id;
let category=document.createElement("p")
category.innerText=element.category;
let product=document.createElement("p")
product.innerText=element.product_type;
let price=document.createElement("h3")
price.innerText=element.price;
let rating=document.createElement("h4")
rating.innerText=element.rating
div.append(img,name,id,category,product,price,rating)
document.querySelector("#container").append(div)
});
}
</script>