Skip to content

Instantly share code, notes, and snippets.

@scottjehl
Created August 21, 2020 15:40
Show Gist options
  • Select an option

  • Save scottjehl/032966e6be88d4859bf3423df93ea5ba to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

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