Skip to content

Instantly share code, notes, and snippets.

@shawncrigger
Forked from scottjehl/whichones.js
Created December 22, 2020 23:26
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 shawncrigger/e8f3d432415cd3bbedf0b0b90e914abe to your computer and use it in GitHub Desktop.
Save shawncrigger/e8f3d432415cd3bbedf0b0b90e914abe to your computer and use it in GitHub Desktop.
which elements are wider than the viewport?
var list = [];
document.querySelectorAll("body *")
.forEach(function(elem){
if(elem.getBoundingClientRect().width > document.body.getBoundingClientRect().width){
list.push(elem.outerHTML.split('>')[0] + '>');
}
});
confirm( "these elements are wider than the viewport:\n\n " + list.join("\n") )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment