Last active
October 15, 2016 18:44
-
-
Save MikhailRoot/5603561d7ea7de7b84d501eff6d0575b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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