This repository has been archived by the owner on Jul 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct_grid.html
77 lines (63 loc) · 1.5 KB
/
product_grid.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
<html>
<template id="productGridTemplate">
<style>
ul {
box-sizing: border-box;
margin: 0;
padding: 0;
list-style-type: none;
border: 1px solid #000;
}
ul::after {
content: " ";
display: table;
clear: both;
}
::content li {
width: 22.5%;
float: left;
margin: 2% 0 0 2%;
}
::content li:nth-child(4n+4) {
margin-right: 2%;
}
::content a {
display: block;
position: relative;
text-decoration: none;
}
::content img {
display: block;
width: 100%;
}
::content img.hover {
display: none;
position: absolute;
top: 0;
}
::content a:hover img.hover {
display: block;
z-index: 1;
}
</style>
<ul>
<content></content>
</ul>
</template>
<script>
var importDoc = document.currentScript.ownerDocument;
var productGridPrototype = Object.create(HTMLElement.prototype);
var gridCallbacks = function(shadow) {
console.log(shadow);
};
productGridPrototype.createdCallback = function() {
var shadow = this.createShadowRoot();
var template = importDoc.querySelector("#productGridTemplate");
shadow.appendChild(template.content.cloneNode(true));
gridCallbacks(shadow);
};
document.registerElement("product-grid", {
prototype: productGridPrototype
});
</script>
</html>