-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
135 lines (121 loc) · 3.28 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta charset="utf-8">
<style>
body {
/*position: relative;*/
}
.header {
width: 100%;
height: 100px;
}
.content {
height: 300px;
overflow-y: auto;
}
table.table-fixed-header {
display: none;
}
table {
/*position: relative;*/
width: 100%;
text-align: center;
border-collapse: collapse;
}
table th {
background-color: #68b1ae;
color: #fff;
}
table th,
table td {
padding: 10px 20px;
border: 1px solid #eee;
}
table tr:nth-child(even) {
background-color: #f2f2f2;
}
.page-table-test {
margin-top: 20px;
}
</style>
</head>
<body>
<div class="header">
<h1>I'm header</h1>
</div>
<div class="content">
<table class="content-table-test">
<thead>
<tr>
<th>姓名</th>
<th>性别</th>
<th>年龄</th>
<th>地址</th>
<th>时间</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<table class="page-table-test">
<thead>
<tr>
<th>姓名</th>
<th>性别</th>
<th>年龄</th>
<th>地址</th>
<th>时间</th>
</tr>
</thead>
<tbody></tbody>
</table>
<script type="text/template" id="table-data-tpl">
{{#each this}}
<tr>
<td>{{name}}</td>
<td>{{sex}}</td>
<td>{{age}}</td>
<td>{{address}}</td>
<td>{{time}}</td>
</tr>
{{/each}}
</script>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/handlebars.js/4.0.10/handlebars.min.js"></script>
<script src="https://github.com/imwtr/jquery-tableHeaderFixed/blob/master/dist/jquery.tableHeaderFixed.min.js"></script>
<script>
function getHtml(source, data) {
var template = Handlebars.compile(source);
return template(data);
};
var data = [{
name: '张飞1',
sex: '男',
age: '12',
address: '我是地址',
time: '12;32'
}, {
name: '张飞2',
sex: '男',
age: '21',
address: '我是地址',
time: '01;32'
}];
for (var i = 0; i < 5; ++i) {
data = data.concat(data);
}
var dataTpl = $('#table-data-tpl').html(),
$pageTableTest = $('.page-table-test')
$contentTableTest = $('.content-table-test');
$pageTableTest.find('tbody').html(getHtml(dataTpl, data))
.end().tableHeaderFixed();
$contentTableTest.find('tbody').html(getHtml(dataTpl, data))
.end().tableHeaderFixed({
fixedInContainer: true,
containerMaxHeight: 300
});
</script>
</body>
</html>