Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ControlledChaos
Forked from scottjehl/whichones.js
Created December 23, 2020 05:12
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 ControlledChaos/e20f99aecab7be6b685ae02afd16f503 to your computer and use it in GitHub Desktop.
Save ControlledChaos/e20f99aecab7be6b685ae02afd16f503 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