-
Notifications
You must be signed in to change notification settings - Fork 31
/
sizes.html
66 lines (54 loc) · 1.39 KB
/
sizes.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
<!doctype html>
<html lang="is">
<head>
<meta charset="utf-8">
<title>Stærðir</title>
<style>
body {
min-height: 200vh;
min-width: 200vw;
}
div {
margin: 50px;
padding: 20px;
border: 10px solid green;
width: 300px;
height: 200px;
background-color: blue;
}
div.border {
box-sizing: border-box;
}
</style>
</head>
<body>
<div></div>
<div class="border"></div>
<script>
function sizes(div) {
const {
offsetHeight, offsetWidth, clientHeight, clientWidth,
} = div;
console.log(`Offset: ${offsetWidth}×${offsetHeight}`);
console.log(`Client: ${clientWidth}×${clientHeight}`);
const {
top, right, bottom, left,
} = div.getBoundingClientRect();
console.log('Bounding rect');
console.log(`top=${top}, right=${right}, bottom=${bottom}, left=${left}`);
}
function scroll(window) {
const { pageXOffset, pageYOffset } = window;
console.log(`Scroll, x=${pageXOffset}, y=${pageYOffset}`);
}
const div = document.querySelector('div');
const borderDiv = document.querySelector('div.border');
console.log('Div með box-sizing: content-box;');
sizes(div);
console.log('Div með box-sizing: border-box;');
sizes(borderDiv);
console.log('Skroll:');
scroll(window);
</script>
</body>
</html>