Skip to content

Instantly share code, notes, and snippets.

@savedario
Created December 17, 2021 10:06
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 savedario/a0d95e82344b19655865386e4d930e29 to your computer and use it in GitHub Desktop.
Save savedario/a0d95e82344b19655865386e4d930e29 to your computer and use it in GitHub Desktop.
List DOM elements wider than viewport
# Selector can be p.class or DIV#id, just like jQuery
var docWidth = document.documentElement.offsetWidth;
[].forEach.call(
document.querySelectorAll('*'),
function(el) {
if (el.offsetWidth > docWidth) {
console.log(el);
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment