function calculatedesktopoffset(length) { return '-' + (length / 2) * math.tan(15 * math.pi / 180) + 'px'; } function makeovaloverlay() { var section01 = document.getelementbyid("section01"); var bannertext = section01.getelementsbyclassname('bannertext')[0]; var bannerimage = section01.getelementsbyclassname('bannerimage')[0]; var oval = section01.getelementsbyclassname('oval')[0]; var $height = bannertext.clientheight; var $width = bannertext.clientwidth; if (window.innerwidth < 992) { bannerimage.style.height = $width + 'px'; oval.style.width = $width * 2.87 + 'px'; // oval overlay needed to be 2.87x the width oval.style.height = $width * 2.87 + 'px'; // of the content, per design oval.style.right = '-' + $width * 0.76 + 'px'; // these are magic numbers, because i oval.style.top = '-' + $width * 0.2 + 'px'; // gave up trying to figure out the trig } else { oval.style.width = $height * 2 + 'px'; // oval overlay need to be 2x the height oval.style.height = $height * 2 + 'px' // of the content, per design oval.style.top = "-50%"; oval.style.right = calculatedesktopoffset($height); bannerimage.style.height = 'auto'; } } makeovaloverlay(); window.onresize = function() { makeovaloverlay() };