Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

BethuelHeldt commented Dec 24, 2020

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