-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
68 lines (64 loc) · 1.55 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>cypress-scroll-test</title>
<style>
body {
padding: 0;
margin: 0;
}
table {
width: 100%;
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
}
th, td {
padding: 8px;
text-align: left;
}
th {
height: 100px;
background-color: #f2f2f2;
position: sticky;
top: 0;
}
tr, td {
scroll-margin-top: 120px;
}
</style>
<script>
const elements = Array.from({ length: 200 }, (_, i) => `
<tr id="row${i + 1}">
<td>Row ${i + 1} - Col 1</td>
<td>Row ${i + 1} - Col 2</td>
<td>Row ${i + 1} - Col 3</td>
</tr>
`).join('');
document.addEventListener('DOMContentLoaded', () => {
document.querySelector('tbody').innerHTML = elements;
});
function scrollIt() {
document.querySelector('#row100').scrollIntoView();
}
</script>
</head>
<body>
<div>
<button onclick="scrollIt()">Scroll Into View</button>
<table>
<thead>
<tr>
<th>One</th>
<th>Two</th>
<th>Three</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</body>
</html>