Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Find the elements that are causing a horizontal scroll. Based on

Debug Horizontal Scroll

(function (d) {
    var w = d.documentElement.offsetWidth,
        t = d.createTreeWalker(d.body, NodeFilter.SHOW_ELEMENT),
    while (t.nextNode()) {
        b = t.currentNode.getBoundingClientRect();
        if (b.right > w || b.left < 0) {
  'outline', '1px dotted red', 'important');


javascript:(function(d){var w=d.documentElement.offsetWidth,t=d.createTreeWalker(d.body,NodeFilter.SHOW_ELEMENT),b;while(t.nextNode()){b=t.currentNode.getBoundingClientRect();if(b.right>w||b.left<0){'outline','1px dotted red','important');console.log(t.currentNode);}};}(document));

This comment has been minimized.

Copy link

@s7ankoff s7ankoff commented Oct 16, 2018

Awesome! Saved my day!


This comment has been minimized.

Copy link

@StanislavJilnicov StanislavJilnicov commented Oct 16, 2020

OMG.... Amazing!!! Thanks a LOT!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.