首页 > 其他 > 详细

getBoundingClientRect()方法

时间:2016-08-26 19:54:24      阅读:203      评论:0      收藏:0      [点我收藏+]
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();
})();

  

getBoundingClientRect()方法

原文:http://www.cnblogs.com/yymb/p/5811516.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!