Skip to content

Instantly share code, notes, and snippets.

@mgiulio
Created June 15, 2015 12:18
Show Gist options
  • Save mgiulio/dff8877d282f305edf23 to your computer and use it in GitHub Desktop.
Save mgiulio/dff8877d282f305edf23 to your computer and use it in GitHub Desktop.
Scripting CSS style sheets...
function installCSS() {
var styleEl = document.createElement('style');
styleEl.id = "inline-editor-css";
document.head.appendChild(styleEl);
var sheet = styleEl.sheet;
var rules = sheet.rules;
sheet.insertRule('.editor { width: 100%; position: relative; display: none; }', rules.length);
sheet.insertRule('.editor textarea { width: 100%; display: block; }', rules.length);
sheet.insertRule('.editor .button.ok { position: absolute; left: 0; top: 100%; }', rules.length);
sheet.insertRule('.editor.visible { display: inline-block; }', rules.length);
installCSS = function() {};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment