Skip to content

Instantly share code, notes, and snippets.

@ViliamKopecky
Created December 8, 2021 10:24
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 ViliamKopecky/028ca6c97d40f05b047aa012a4b167ca to your computer and use it in GitHub Desktop.
Save ViliamKopecky/028ca6c97d40f05b047aa012a4b167ca to your computer and use it in GitHub Desktop.
Finding elements wider than screen
var docWidth = document.documentElement.offsetWidth;
[].forEach.call(document.querySelectorAll("*"), function (el) {
if (el.closest("svg")) {
return null;
}
if (
el.offsetWidth > docWidth ||
el.getBoundingClientRect().right > docWidth
) {
console.log({
el,
box: el.getBoundingClientRect(),
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment