Skip to content

Instantly share code, notes, and snippets.

@zax4r0
Created December 26, 2021 21:02
Show Gist options
  • Save zax4r0/e6af323f0109cd7bc041502216cc6fe2 to your computer and use it in GitHub Desktop.
Save zax4r0/e6af323f0109cd7bc041502216cc6fe2 to your computer and use it in GitHub Desktop.

Finding/Fixing Unintended Body Overflow


In some cases, there might be an element that is literally wider than the document is, which might cause horizontal overflow scrolling. You could use a little JavaScript to help you find the culprit.

open DevTools in browser and run this on console u will get the element causing overflow

var docWidth = document.documentElement.offsetWidth;

[].forEach.call(
  document.querySelectorAll('*'),
  function(el) {
    if (el.offsetWidth > docWidth) {
      console.log(el);
    }
  }
);

Kanged From Here BTW

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