Find element that is causing the showing of horizontal scrollbar in Google Chrome

后端 未结 5 1493
天命终不由人
天命终不由人 2020-12-22 22:46

When I size my Chrome window to 328 x 455 pixels I still see a horizontal scrollbar. How can I find out which element is causing this? I\'ve been looking elements via the de

5条回答
  •  误落风尘
    2020-12-22 23:13

    Find the culprit by copy paste the below js code in your URL address bar.

    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){t.currentNode.style.setProperty('outline','1px dotted red','important');console.log(t.currentNode);}};}(document));
    

提交回复
热议问题