Created
August 21, 2020 15:40
-
-
Save scottjehl/032966e6be88d4859bf3423df93ea5ba to your computer and use it in GitHub Desktop.
which elements are wider than the viewport?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Thank you... Really helpful script for my students.