Skip to content

Instantly share code, notes, and snippets.

@aiherrera
Created April 14, 2021 21:50
Show Gist options
  • Save aiherrera/bb6229acb3dee62a30489b1cd227675d to your computer and use it in GitHub Desktop.
Save aiherrera/bb6229acb3dee62a30489b1cd227675d to your computer and use it in GitHub Desktop.
Detector for elements who breaks the box model
const all_elements = document.getElementsByTagName("*");
let rect;
const offsetWidth = document.documentElement.offsetWidth;
for (let i = 0; i < all_elements.length; i++) {
rect = all_elements[i].getBoundingClientRect();
if (rect.right > offsetWidth || rect.left < 0){
// SHOW BREAKING ELEMENTS IN THE CONSOLE
console.log(all_elements[i]);
// SET BORDER TO BREAKING ELEMENTS
all_elements[i].style.border = '1px solid #EF3E36';
}
}
@aiherrera
Copy link
Author

Just copy it on the browser console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment