Skip to content

Instantly share code, notes, and snippets.

@davejtoews
Created August 15, 2019 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davejtoews/790a1ad6c59773064cdc118b2f1b41e4 to your computer and use it in GitHub Desktop.
Save davejtoews/790a1ad6c59773064cdc118b2f1b41e4 to your computer and use it in GitHub Desktop.
Detect elements which are overflowing your window and causing a side scroll.
[].forEach.call(document.querySelectorAll('*'), function(element) {
if (element.offsetLeft + element.offsetWidth > window.innerWidth) {
console.log(element);
}
});
@davejtoews
Copy link
Author

Paste the above into your console or into a javascript file in a section of code that runs after page load. Any element which overflows the window will be output to the console.

@davejtoews
Copy link
Author

As pointed out by @sinan-evanshunt. This can also be solved with CSS

*, *:before, *:after {outline: 1px dotted red !important;}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment