-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (31 loc) · 1.25 KB
/
script.js
File metadata and controls
41 lines (31 loc) · 1.25 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
var width = 0
var height = 0
// output targets (cells in a table)
var bodyWidth = document.querySelector('.body-width')
var bodyHeight = document.querySelector('.body-height')
var fontSize = document.querySelector('.font-size');
var h1Width = document.querySelector('.h1-box-width');
var onresize = function () {
width = document.body.clientWidth;
height = document.body.clientHeight;
bodyWidth.innerHTML = width
bodyHeight.innerHTML = height
var el = document.querySelector('.section-h1');
// get & output h1 font-size
var styleFZ = window.getComputedStyle(el, null).getPropertyValue('font-size');
// var getFontSize = parseFloat(styleFZ);
fontSize.innerHTML = styleFZ;
// end
// get & output h1 width integer
var styleBW = window.getComputedStyle(el, null).getPropertyValue('width');
var regExp = /\d+/g;
var match = styleBW.match(regExp);
// console.log(match[0] + 'px')
h1Width.innerHTML = match[0] + 'px'
// end
// h1Width.innerHTML = Math.floor(ParseInt(styleBW));
// h1Width.innerHTML = styleBW;
}
window.addEventListener("resize", onresize);
// now you have a proper float for the font size (yes, it can be a float, not just an integer)
// el.style.fontSize = (fontSize + 1) + 'px';