-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdemo.html
47 lines (46 loc) · 1.13 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>jstyle</title>
<script src="jstyle.js"></script>
<script>
jstyle.setVars({
/*
* Variables
*/
main:'#0C0',
space:'2em',
// assign a value by a function
mainLight:function(){
// css is a reference to this json itself
return this.vars.main.replace(/0/g, '8');
}
}).addStyle({
/*
* Style definition, css like but in JSON:
*
* with commas "," instead of semi-colons ";"
* and some reserved js words can't be used as a property, i.e: "float" as below
* to overcome this, place the property name between quotes/double quotes
*/
'body':{
background:'#121',
color:'$main'
},
'.hello':{
border:'solid 1px $mainLight',
background:'#040', //normal assignment (no variable)
'float':'left',
padding:'$space',
margin:'$space'
}
});
// example below on how to load a static css from a file - disabled
// jstyle().addLink('http://beebole-apps.com/themes/theme.css')
</script>
</head>
<body>
<div class="hello">Hello Wrrld !</div>
</body>
</html>