Skip to content

Instantly share code, notes, and snippets.

@scottjehl
Created August 21, 2020 15:40
  • Star 63 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save scottjehl/032966e6be88d4859bf3423df93ea5ba 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") )
@BethuelHeldt
Copy link

Thank you... Really helpful script for my students.

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