Brains Coders

Brains Engineering Blog

Finding element(s) causing body horizontal overflow

A quick javascript to execute in the console to find the elements that are causing the  horizontal scrollbar to appear:


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