Skip to content

Instantly share code, notes, and snippets.

@the1sky
Last active May 11, 2016 09:12
Show Gist options
  • Save the1sky/c80e028c31960dba72a7b829ba842a15 to your computer and use it in GitHub Desktop.
Save the1sky/c80e028c31960dba72a7b829ba842a15 to your computer and use it in GitHub Desktop.
兼容IE的getBoundClientRect
function getRect (element) {
var rect = element.getBoundingClientRect();
var top = document.documentElement.clientTop;
var left= document.documentElement.clientLeft;
return{
top : rect.top - top,
bottom : rect.bottom - top,
left : rect.left - left,
right : rect.right - left
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment