Last active
September 2, 2016 07:38
-
-
Save cmawhorter/3a152aa8366c4b557ba7 to your computer and use it in GitHub Desktop.
Checks every element in a page to see if it's total width is wider than the container (viewport by default). Might be useful to track down unwanted horizontal scroll bars.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Deps on jquery | |
| (function(container) { | |
| var viewportWidth = $(container).width(); | |
| console.group('Overflow Check'); | |
| console.info('Container Width: %s', viewportWidth); | |
| $('*').each(function() { | |
| var $this = $(this); | |
| var elWidth = $this.outerWidth(true); | |
| if (elWidth > viewportWidth) { | |
| console.warn('Overflow by %spx!', elWidth - viewportWidth, loggingVars, this); | |
| } | |
| else { | |
| console.debug('Element OK', elWidth, this); | |
| } | |
| }); | |
| console.groupEnd('Overflow Check'); | |
| })(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment