getBoundingClientRect 方法 有6个属性 top 、bottom、right、left、width和height
ie9以下浏览器只支持 getBoundingClientRect 方法的 top 、bottom、right、left属性;
ie9 和其它浏览器支持 getBoundingClientRect 方法 有6个属性 top 、bottom、right、left、width和height;
问题
想要确定一个Web页面元素的当前宽度width和高度height;
解决方法:
//页面宽度 = right - left
var width = ele.getBoundingClientRect().right-ele.getBoundingClientRect().left;
//页面高度 = right - left
var width = ele.getBoundingClientRect().bottom -ele.getBoundingClientRect().top;