Skip to content

Instantly share code, notes, and snippets.

@Sleavely
Created February 28, 2017 13:07
Show Gist options
  • Save Sleavely/5cb70678d840f6408c2d420ecb0b3cff to your computer and use it in GitHub Desktop.
Save Sleavely/5cb70678d840f6408c2d420ecb0b3cff to your computer and use it in GitHub Desktop.
(function () {
var newcss = '#myDiv { -webkit-filter: blur(8px) grayscale(1); }';
newcss += '#hideSomething { display: none; }';
newcss += '#makeItGreen { background: #00ff00; }';
if ('\v' == 'v') /* ie only */ {
document.createStyleSheet().cssText = newcss;
} else {
var tag = document.createElement('style');
tag.type = 'text/css';
document.getElementsByTagName('head')[0].appendChild(tag);
tag[(typeof document.body.style.WebkitAppearance == 'string') /* webkit only */ ? 'innerText' : 'innerHTML'] = newcss;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment