-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresize.html
33 lines (31 loc) · 944 Bytes
/
resize.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
<!doctype html>
<html>
<head>
<title>Browser resizing practice</title>
</head>
<body>
<style>
body{margin:0; padding:0; background:#999; color:#ddd;}
#wrapper{width:80%; margin:0 auto; background:#fff; display:block; padding:50px;}
#content{width:50%; background:#333; margin:100px auto 0 auto; padding:10px 20px; text-align:center;}
</style>
<div id="wrapper">
<div id="content">
<h1>This title should get resized</h1>
<div id="textblock">
<p>This block of text should also get resized</p>
</div>
</div>
</div>
</body>
<script>
var content = document.getElementById('content');
window.onresize = function(){
var currWidth = window.innerWidth;
var newWidth = window.innerWidth;
var currHeight = content.offsetHeight;
content.style.height = ( (currWidth > newWidth) ? (currHeight - 21) : (currHeight - 19) ) + 'px';
console.log(content.offsetHeight);
}
</script>
</html>