Size and coordinates as a percentage?

In CSS, the percentages are not always and not everywhere, so I thought that JS would be more appropriate. The point is that when you change the window size to calculate and change the sizes of items.
var W,H, WPerc, HPerc;

window.onload = function _Init() {
_Resize();
}

window.onresize = _Resize;

function _Resize() {
 W = window.outerWidth;
 H = window.outerHeight;
 WPerc = W / 100;
 HPerc = H / 100;
PercentSize();
}

PercentSize function() {
 var items = document.getElementsByTagName('button');
 for (var i=0; i<items.length; i++ ) { items[i].style.position="absolute" ; var w="items[i].offsetWidth;" h="items[i].offsetHeight;" x="items[i].offsetLeft;" y="items[i].offsetTop;" items[i].offsetwidth="WPerc" * w; items[i].offsetheight="HPerc" h; items[i].offsetleft="WPerc" x; items[i].offsettop="HPerc" y; } }< code></items.length;>
July 9th 19 at 13:45
1 answer
July 9th 19 at 13:47
Solution

Find more questions by tags JavaScript