Created
April 14, 2021 21:50
-
-
Save aiherrera/bb6229acb3dee62a30489b1cd227675d to your computer and use it in GitHub Desktop.
Detector for elements who breaks the box model
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
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'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just copy it on the browser console