-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
83 lines (69 loc) · 1.4 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
71
72
73
74
75
76
77
78
79
80
81
82
83
<html>
<head>
<title>StickyStuff Demo</title>
<style>
/* required: core css & reset table */
table {
margin: 0;
padding: 0;
border: 0;
}
.stickystuff-cloned {
margin-top:0;
position: fixed;
top:0;
z-index:999;
}
/* your css */
table {
width:400px;
margin:200px 0px 1000px 200px;
}
th, td {
width:100px;
height:50px;
border:1px solid #000;
}
#tbl thead {
background:#ddd;
}
.stickystuff-cloned {
background:cyan;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="stickystuff.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<table id="tbl">
<thead>
<tr>
<th class="col1"> Column 1 </th>
<th class="col2"> Column 2 </th>
<th class="col3"> Column 3 </th>
<th class="col4"> Column 4 </th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script>
// generate dummy data
var html = '';
for (var i=100; i; i--) {
html += '<tr>' +
'<td>' + (Math.random()*1000).toFixed(2) + '</td>' +
'<td>' + (Math.random()*1000).toFixed(2) + '</td>' +
'<td>' + (Math.random()*1000).toFixed(2) + '</td>' +
'<td>' + (Math.random()*1000).toFixed(2) + '</td>' +
'</tr>';
}
$("#tbl tbody").html(html);
$(document).ready(function(){
$("#tbl").stickystuff({
throttle:10
});
});
</script>
</body>
</html>