forked from KenyeeC/eleFixed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
70 lines (66 loc) · 1.86 KB
/
demo.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<style>
#block {
height: 200px;
background-color: #f1f1f0;
}
table{
border-collapse:collapse;
}
tr{
border: 1px solid #efefef;
}
thead {
background-color: #333;
}
thead th {
vertical-align: bottom;
background-color: #9c9c9c;
}
</style>
<div id="block"></div>
<table class="table">
<thead>
<tr>
<th>title</th>
<th>title</th>
<th>title</th>
<th>title</th>
<th>titlelonglonglong longlonglonglong</th>
<th>title</th>
<th>title</th>
<th>titlelonglonglonglong longlonglonglonglong</th>
</tr>
</thead>
<tbody></tbody>
</table>
</body>
<script>
var tbody = document.getElementsByTagName('tbody')[0]
var html = ''
for(var i = 0; i< 50; i++){
html += '<tr><th>value</th><th>value</th><th>value</th><th>value</th><th>value</th><th>value</th><th>value</th><th>value</th></tr>'
}
tbody.innerHTML = html
</script>
<script src="./eleFixed.min.js"></script>
<script>
// add an instance
eleFixed.push({
target: document.getElementsByTagName('thead')[0], // it must be a HTMLElement
offsetTop: 210 // height from window offsetTop
})
// delete one instance
// eleFixed.delete(document.getElementsByTagName('thead')[0])
// distory eleFixed
// eleFixed.distory()
</script>
</html>