Created
November 11, 2020 10:18
-
-
Save Fania/2c50eb46b95fa3e2e6220a9ac0e7106d to your computer and use it in GitHub Desktop.
Highlight Overflowing Elements
This file contains 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
let w = document.documentElement.offsetWidth; | |
let t = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT); | |
let b; | |
while (t.nextNode()) { | |
b = t.currentNode.getBoundingClientRect(); | |
if (b.right > w || b.left < 0) { | |
t.currentNode.style.setProperty('outline', '1px dotted red', 'important'); | |
console.log(t.currentNode); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment