Skip to content

Instantly share code, notes, and snippets.

@MikhailRoot
Last active October 15, 2016 18:44
Show Gist options
  • Save MikhailRoot/5603561d7ea7de7b84d501eff6d0575b to your computer and use it in GitHub Desktop.
Save MikhailRoot/5603561d7ea7de7b84d501eff6d0575b to your computer and use it in GitHub Desktop.
// originaly based on code from https://css-tricks.com/findingfixing-unintended-body-overflow/
// improved to handle absolute positioned elements shifted to right making overflow happend.
function findOverflow(){
var docWidth = document.documentElement.offsetWidth;
[].forEach.call(
document.querySelectorAll('*'),
function(el) {
var rect= el.getBoundingClientRect();
if (el.offsetWidth > docWidth ||rect.right>docWidth) {
console.log(el);
}
}
);
}
findOverflow(); // call it as script loads. Also you can call it later manually from a console.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment