-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponsive.html
47 lines (43 loc) · 1.04 KB
/
responsive.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Window</title>
<style>
body, html {
margin: 0;
padding: 0;
overflow: hidden;
height: 100%;
}
.content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 24px;
white-space: nowrap;
}
</style>
</head>
<body>
<div class="content">
<p>This window is responsive. <br /> It will make sure this text is always visible in its entirety without any wrapping</p>
</div>
<script>
window.addEventListener('resize', function() {
checkOverflow();
});
function checkOverflow() {
var content = document.querySelector('.content');
if (content.scrollWidth > window.innerWidth || content.scrollHeight > window.innerHeight) {
window.close()
}
}
window.onload = function() {
checkOverflow();
};
</script>
</body>
</html>