With MooCss you can write Css as Javascript objects (just like Element.Style) to a style tag in the document head
First you have to include the javascript files and css file in the head of your html document
<script src="../Source/MooCss.js" type="text/javascript"></script>
There are two classes, MooCss and MooCssStyle. First you create a style for a selector, for example '.foo' and apply the styles. Secondly you add this MooCssStyle instance to the MooCss instance and call the MooCss.write method to actually write the CSS to your document head.
var style = new MooCss()
.setStyle(new MooCssStyle('.foo',{
background: '#FF9900',
color: 'white',
padding: 20
}))
.setStyle(new MooCssStyle('pre',{
border: '1px solid black'
}))
.setStyle({
'background': '#EEE'
},'body')
.write();
document.addEvent('click',function(){
style.setStyle(style.getStyle('body').set('font-weight','bold')).write();
});
new MooCss(options);
The function to set a style
css.setStyle(style[,selector]);
The function to get a style
css.getStyle(selector);
The function to write the css to the stylesheet
css.write();
If the styles are written to the stylesheet, you can fetch the css with this method
css.getCss();
document.id(css);
If the styles are written to the stylesheet, you can fetch the css with this method
css.getCss();
var style new MooCssStyle(selector[,styles]);
The function to set another selector
style.setSelector(selector);
The function to set another selector
style.getSelector();
The function to set styles
style.set(property,value);
The function to get styles
style.get(property);
Return the CSS string
style.toCss();
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus