getBoundingClientRect()方法

it2022-05-08  7

getBoundingClientRect 方法 有6个属性 top 、bottom、right、left、width和height   ie9以下浏览器只支持 getBoundingClientRect 方法的 top 、bottom、right、left属性; ie9 和其它浏览器支持 getBoundingClientRect 方法 有6个属性 top 、bottom、right、left、width和height; 根据getBoundClientRect().width这个值来做字体的适配 (function () { var html = document.documentElement; function onWindowResize() { html.style.fontSize = html.getBoundingClientRect().width / 20 + 'px'; } window.addEventListener('resize', onWindowResize); onWindowResize(); })();

  

转载于:https://www.cnblogs.com/yymb/p/5811516.html


最新回复(0)