js get vh value

Solutions on MaxInterview for js get vh value by the best coders in the world

showing results for - "js get vh value"
Maria José
29 Apr 2017
1function vh(v) {
2  var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
3  return (v * h) / 100;
4}
5
6function vw(v) {
7  var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
8  return (v * w) / 100;
9}
10
11function vmin(v) {
12  return Math.min(vh(v), vw(v));
13}
14
15function vmax(v) {
16  return Math.max(vh(v), vw(v));
17}
18console.info(vh(20), Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
19console.info(vw(30), Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
20console.info(vmin(20));
21console.info(vmax(20));