JS获取元素相对窗口的位置和大小
利用:getBoundingClientRect 获取元素相对窗口的位置和大小
function test(){
var box = document.getElementById("btn1");
var pos = box.getBoundingClientRect();
console.log("top:"+pos.top +
"left:"+pos.left +
"bottom:"+pos.bottom +
"right:"+pos.right +
"width:"+pos.width +
"height:"+pos.height);
}
fffffffffffffffff
test red font.

浙公网安备 33010602011771号