Skip to content

Instantly share code, notes, and snippets.

@ControlledChaos
Forked from scottjehl/whichones.js
Created December 23, 2020 05:12
Show Gist options
  • Save ControlledChaos/e20f99aecab7be6b685ae02afd16f503 to your computer and use it in GitHub Desktop.
Save ControlledChaos/e20f99aecab7be6b685ae02afd16f503 to your computer and use it in GitHub Desktop.

Revisions

  1. @scottjehl scottjehl created this gist Aug 21, 2020.
    8 changes: 8 additions & 0 deletions whichones.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    var list = [];
    document.querySelectorAll("body *")
    .forEach(function(elem){
    if(elem.getBoundingClientRect().width > document.body.getBoundingClientRect().width){
    list.push(elem.outerHTML.split('>')[0] + '>');
    }
    });
    confirm( "these elements are wider than the viewport:\n\n " + list.join("\n") )