获取元素相对于视窗的位置
2017-07-03 本文已影响0人
C_Y大渔
getBoundingClientRect();
兼容所有浏览器,
取得元素矩阵,返回
元素左上角坐标距
视窗口的
left,top,right,bottom值
var parentDiv=document.getElementById("newsbox").getBoundingClientRect(); //对于视窗的位置
getBoundingClientRect();
兼容所有浏览器,
取得元素矩阵,返回
元素左上角坐标距
视窗口的
left,top,right,bottom值
var parentDiv=document.getElementById("newsbox").getBoundingClientRect(); //对于视窗的位置