Created
July 4, 2012 18:37
-
-
Save replete/3048826 to your computer and use it in GitHub Desktop.
Add class to <body> based on viewport width (IE7+, possibly IE6+)
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
var d = document, | |
b = d.getElementsByTagName("body"), | |
w = window, | |
c = "className", | |
v = (function() { return w.innerWidth || d.documentElement.clientWidth }), | |
r = function () { | |
i = v(); | |
if (i < 181) { b[0][c] = "max-180"; return } | |
if (i < 246) { b[0][c] = "max-245"; return } | |
else { b[0][c] = "" } | |
} | |
w.onresize = r; | |
r(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment