-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
179 lines (169 loc) · 6.96 KB
/
index.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CSSOBJ DEMO</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!--[if lte IE 9]>
<script type="text/javascript" src="http://cdn.staticfile.org/es5-shim/3.4.0/es5-shim.min.js"></script>
<script type="text/javascript" src="http://cdn.staticfile.org/json3/3.3.2/json3.min.js"></script>
<![endif]-->
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/cssobj.iife.js"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/cssobj-plugin-default-unit.iife.js"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/cssobj-plugin-flexbox.iife.js"></script>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
<h1>cssobj demo page</h1>
<div align="left"><a href="https://github.com/cssobj/cssobj">Github Repo</a></div>
<a name="demo1" id="demo1"></a>
<h3><a href="#demo1">#</a> Box size adjustment <span>(with <a href="https://github.com/cssobj/cssobj-plugin-default-unit" target="_blank">default-unit</a> plugin)</span></h3>
<div>
<div class="demo1_con">
<div class="demo1_input">
<label>lock ratio:<input style="width:20px" type="checkbox" onclick="toggleDemo1Height()"></label>
width: <input type="number" oninput="demo1obj['.box'].width = this.value; demo1css.update()" onblur="demo1obj['.box'].width = this.value; demo1css.update()" value="30">
<span>height: <input id="demo1_height" type="number" oninput="demo1obj['.box'].height = this.value; demo1css.update()" onblur="demo1obj['.box'].height = this.value; demo1css.update()" value="30"></span>
</div>
<div class="demo1area">
<div class="box_demo1_"></div>
<div class="box_demo1_"></div>
<div class="box_demo1_"></div>
<div class="box_demo1_"></div>
<div class="box_demo1_"></div>
<br clear="both">
</div>
<div>cssText from above CSSOM</div>
<div id="demo1_diff" class="diff"></div>
<textarea id="demo1_text" readonly class="readonly"></textarea>
</div>
</div>
<script type="text/javascript" src="demo1.js"></script>
<hr>
<a name="demo-anim" id="demo-anim"></a>
<h3><a href="#demo-anim">#</a> Animation</h3>
<div>
<div class="demo-anim-area">
<div class="box_demo-anim_ box_demo1_"></div>
<div class="box_demo-anim_ box_demo1_"></div>
<div class="box_demo-anim_ box_demo1_"></div>
<br clear="both">
</div>
<div>cssText from above CSSOM</div>
<div id="demo_anim_diff" class="diff"></div>
<textarea id="demo_anim_text" readonly class="readonly"></textarea>
</div>
<script type="text/javascript" src="demo-anim.js"></script>
<hr>
<a name="demo-conditional" id="demo-conditional"></a>
<h3><a href="#demo-conditional">#</a> conditional apply css</h3>
<div>
<a href="test/test.html" target="_blank">See Demo</a>
</div>
<hr>
<a name="demo-prefixer" id="demo-prefixer"></a>
<h3><a href="#demo-prefixer">#</a> Auto vendor prefixer</h3>
<div>
<a href="button/" target="_blank">See Demo</a>
<em>(Please open it in different browser)</em>
</div>
<hr>
<a name="demoprefixer" id="demoprefixer"></a>
<h3><a href="#demoprefixer">#</a> nested selector + auto vendor prefixer</h3>
<div>
<div class="demo2_con">
<div class="demo2_input">
<div>HTML</div>
<textarea id="demo2_html" readonly class="readonly">
<ul>
<li><strong>item 1</strong>item <span>content</span>A</li>
<li><strong>item 2</strong>item <span>content</span>B</li>
<li><strong>item 3</strong>item <span>content</span>C</li>
</ul></textarea>
<div>CSS (<strong>try to change!</strong>)</div>
<textarea id="demo2_obj" style="height:222px">
{
ul:{
listStyleType: 'disc',
flex:1,
display:'flex',
// for IE
imeMode: 'auto',
background: ['-webkit-linear-gradient(grey, white)', 'linear-gradient(grey, white)'],
transform:'scale(0.8)',
borderImage: 'none',
li:{
color:'#999',
'span,strong':{
color:'red',
'&:after':{
content:'": "'
}
}
}
}
}
</textarea>
</div>
<div id="demo2area"></div>
<div>cssText from above CSSOM</div>
<div id="demo2_diff" class="diff"></div>
<textarea id="demo2_text" readonly class="readonly"></textarea>
</div>
</div>
<script type="text/javascript" src="demo2.js"></script>
<hr>
<a name="demomedia" id="demomedia"></a>
<h3><a href="#demomedia">#</a> @media rule in iframe page (Modern & IE >= 8)</h3>
<div>iframe width: <input id="demo3_input" onblur="$('mediaIframe').width=this.value" value="320">
<a href="javascript:;" onclick="$('demo3_input').value = $('mediaIframe').width=300">300</a>
<a href="javascript:;" onclick="$('demo3_input').value = $('mediaIframe').width=400">400</a>
<a href="javascript:;" onclick="$('demo3_input').value = $('mediaIframe').width=500">500</a>
<a href="play/" target="_blank">open in new window</a></div>
<div>
<iframe src="play/" width="320" height="600" id="mediaIframe" style="border:1px solid black; margin-top:10px;" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>
</div>
<hr>
<a name="demo4" id="demo4"></a>
<h3><a href="#demo4">#</a> Local Class names</h3>
<div>
<div>CSS (<strong>try to change!</strong>)</div>
<textarea id="demo4_obj" style="height:200px"></textarea>
<div>cssText from above CSSOM</div>
<div id="demo4_diff" class="diff"></div>
<textarea id="demo4_text" readonly class="readonly" style="height:150px"></textarea>
</div>
<script type="text/javascript" src="demo4.js"></script>
<hr>
<a name="demo5" id="demo5"></a>
<h3><a href="#demo5">#</a> Set css prop using function</h3>
<strong>box1 have same width & height<br>
box3's height is twice of box1<br>
box2's height is sum of box1 & 3<br><br>
<div>
<div>CSS (<strong>try to change!</strong>)</div>
<textarea id="demo5_obj" style="height:250px">
{
'.box1':{
$id:'box1',
width:10,
height: function(prev,node,result) {return node.rawVal.width}
},
'.box2':{
$order:2,
height: function(prev,node,result) {return result.ref.box1.rawVal.height + result.ref.box3.rawVal.height}
},
'.box3':{
$id:'box3',
$order:1,
height: function(prev,node,result) {return result.ref.box1.rawVal.width*2}
}
}
</textarea>
<div>cssText from above CSSOM</div>
<div id="demo5_diff" class="diff"></div>
<textarea id="demo5_text" readonly class="readonly" style="height:150px"></textarea>
</div>
<script type="text/javascript" src="demo5.js"></script>
</body>
</html>