-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexample.html
More file actions
49 lines (49 loc) · 1.2 KB
/
example.html
File metadata and controls
49 lines (49 loc) · 1.2 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script src="example.js"></script>
<script>
var scrollTo = example;
function randomize() {
var target = document.querySelector('.target');
target.style.top = Math.round(Math.random() * 1000) + 'px';
target.style.left = Math.round(Math.random() * 1000) + 'px';
}
function scroll() {
var target = document.querySelector('.target');
scrollTo(target);
}
</script>
<style>
.container {
overflow: auto;
margin: 40px;
position: relative;
}
.target {
width: 40px;
height: 40px;
background: black;
position: absolute;
}
.bar {
position: fixed;
top: 0;
}
</style>
</head>
<body>
<div class="container" style="background: red; width: 600px; height: 400px">
<div class="container" style="background: blue; width: 800px; height: 600px">
<div class="container" style="background: lime; width: 1000px; height: 800px">
<div class="target"></div>
</div>
</div>
</div>
<div class="bar">
<button onclick="randomize()">Randomize</button>
<button onclick="scroll()">Scroll To</button>
</div>
</body>
</html>