Skip to content

Instantly share code, notes, and snippets.

@siriokun
Forked from replete/getLayoutBreakpoint.js
Created May 10, 2014 00:11
Show Gist options
  • Save siriokun/c4ce7510aa42c7a6e6f5 to your computer and use it in GitHub Desktop.
Save siriokun/c4ce7510aa42c7a6e6f5 to your computer and use it in GitHub Desktop.
/*
LayoutBreakpoints - Sync JS with your CSS media queries - yay!
After painfully discovering that there is no hope for IE7 (and others) to read
content properties with generated content, I resolved to this solution.
If it doesn't work for you, you could easily change getElementsByTagName to
getElementsById and pop an ID attribute onto an element of your choosing.
See an example here: http://replete.github.io/FitTextNow/example.html (view-source)
-@replete
*/
var getLayoutBreakpoint = function () {
var el = document.getElementsByTagName("head")[0],
bp = window.getComputedStyle ? getComputedStyle(el,'').getPropertyValue('font-family') : el.currentStyle.fontFamily;
return bp.replace(/"|'|`/g, "")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment