Skip to content

Instantly share code, notes, and snippets.

@Fania
Created November 11, 2020 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fania/2c50eb46b95fa3e2e6220a9ac0e7106d to your computer and use it in GitHub Desktop.
Save Fania/2c50eb46b95fa3e2e6220a9ac0e7106d to your computer and use it in GitHub Desktop.
Highlight Overflowing Elements
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