-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.html
315 lines (283 loc) Β· 16.7 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Deciphering the CSS property syntax</title>
<meta name="description" content="Have you tried reading a CSS specification then got stumped by the property value syntax? What do all those *&||[]#{}?+ mean? We'll work through them and find out that it actually isn't that hard.">
<meta name="author" content="Chen Hui Jing">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/jing.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>Deciphering the CSS property syntax <span class="emoji" role="img" tabindex="0" aria-label="nerd face">🤓</span></h1>
<p><small>By <a href="https://www.chenhuijing.com/">Chen Hui Jing</a> / <a href="http://twitter.com/hj_chen">@hj_chen</a></small></p>
</section>
<section>
<h2>Have you ever seen a CSS specification? <span class="emoji" role="img" tabindex="0" aria-label="thinking face">🤔</span></h2>
<p class="fragment">Meet <a href="https://www.w3.org/TR/css3-grid-layout/">CSS Grid Layout Module Level 1</a>.</p>
</section>
<section>
<h2>Backus Naur Form (BNF)</h2>
<ul>
<li class="fragment">Introduced by <strong>John Backus</strong> and <strong>Peter Naur</strong></li>
<li class="fragment">A context-free notation method to describe the syntax of a language.</li>
<li class="fragment">The CSS property value syntax is loosely based on BNF notation.</li>
</ul>
<pre class="fragment"><code><symbol> ::= __expression__</code></pre>
<p class="fragment">The stuff on the left can be replaced by the stuff on the right.</p>
</section>
<section>
<h2>A BNF Sandwich <span class="emoji" role="img" tabindex="0" aria-label="burger">🍔</span></h2>
<p class="fragment">A sandwich consists of a <span class="ingredient">lower slice of bread</span>, <span class="ingredient">mustard</span> or <span class="ingredient">mayonnaise</span>; optional <span class="ingredient">lettuce</span>, an optional slice of <span class="ingredient">tomato</span>; two to four slices of either <span class="ingredient">bologna</span>, <span class="ingredient">salami</span>, or <span class="ingredient">ham</span> (in any combination); one or more slices of <span class="ingredient">cheese</span>, and a <span class="ingredient">top slice of bread</span>.</p>
<code class="fragment alt">sandwich ::= lower_slice [ mustard | mayonnaise ] lettuce? tomato? [ bologna | salami | ham ]{2,4} cheese+ top_slice</code>
<p class="fragment"><small><em>Analogy from <a href="https://alistapart.com/article/readspec">How to Read W3C Specs</a>.</em></small></p>
</section>
<section>
<h2>Component Value Types</h2>
<table style="font-size:85%;">
<thead>
<tr>
<th style="width:20%;">Value type</th>
<th>Description</th>
<th style="width:28%;">Example</th>
</tr>
</thead>
<tbody>
<tr class="fragment">
<td>Keyword values</td>
<td>Actual value used; No quotation marks or angle brackets</td>
<td><code class="alt">auto</code> or <code class="alt">none</code></td>
</tr>
<tr class="fragment">
<td>Basic data types</td>
<td>To be replaced with actual values; Angle brackets</td>
<td><code class="alt"><length></code> or <code class="alt"><percentage></code></td>
</tr>
<tr class="fragment" style="vertical-align:top;"">
<td>Property data type</td>
<td>Uses same set of values as defined property, usually used for shorthand property definitions; Quotation marks within angle brackets</td>
<td><code class="alt"><'grid-template-rows'></code> or <code class="alt"><'flex-basis'></code></td>
</tr>
<tr class="fragment">
<td>Non-property data type</td>
<td>Set of values is defined somewhere else in the specification, usually near its first appearance; Angle brackets only</td>
<td><code class="alt"><line-names></code> or <code class="alt"><track-repeat></code></td>
</tr>
</tbody>
</table>
</section>
<section>
<section>
<h2>Component Value Combinators</h2>
</section>
<section>
<h3>Space-separated list of values</h3>
<p>All values must occur in specified order</p>
<code class="alt" style="display:inline-block;"><'property-name'> = value1 value2 value3</code><p>↓</p><pre><code>.selector { property: value1 value2 value3; }</code></pre>
</section>
<section>
<h3>&&</h3>
<p>All values must occur, order doesn't matter</p>
<code class="alt" style="display:inline-block;"><'property-name'> = value1 && value2</code><p>↓</p><pre><code>.selector { property: value1 value2; }
.selector { property: value2 value1; }</code></pre>
</section>
<section>
<h3>|</h3>
<p>Only 1 value must occur</p>
<code class="alt" style="display:inline-block;"><'property-name'> = value1 | value2 | value3</code><p>↓</p><pre><code>.selector { property: value1; }
.selector { property: value2; }
.selector { property: value3; }</code></pre>
</section>
<section>
<h3>||</h3>
<p>1 or more values must occur, order doesn't matter</p>
<code class="alt" style="display:inline-block;"><'property-name'> = value1 || value2 || value3</code><p>↓</p><pre><code>.selector { property: value3; }
.selector { property: value2 value3; }
.selector { property: value1 value2 value3; }
and so on...</code></pre>
</section>
<section>
<h3>[]</h3>
<p>Components belong to a single grouping</p>
<code class="alt" style="display:inline-block;"><'property-name'> = [ value1 | value2 ] value3</code><p>↓</p><pre><code>.selector { property: value1 value3; }
.selector { property: value2 value3; }
</code></pre>
</section>
</section>
<section>
<section>
<h2>Component Value Multipliers</h2>
</section>
<section>
<h3>?</h3>
<p>Optional value, can occur 0 or 1 time</p>
<code class="alt" style="display:inline-block;"><'property-name'> = value1 [, value2 ]?</code><p>↓</p><pre><code>.selector { property: value1; }
.selector { property: value1, value2; }
</code></pre>
</section>
<section>
<h3>*</h3>
<p>Optional value, can occur 0 or many times, multiple values are comma-separated</p>
<code class="alt" style="display:inline-block;"><'property-name'> = value1 [, <value2>]*</code><p>↓</p><pre><code>.selector { property: value1; }
.selector { property: value1, <value2>; }
.selector { property: value1, <value2>, <value2>, <value2>; }
and so on...</code></pre>
</section>
<section>
<h3>+</h3>
<p>Can occur 1 or many times, multiple values are space-separated</p>
<code class="alt" style="display:inline-block;"><'property-name'> = <value>+</code><p>↓</p><pre><code>.selector { property: <value>; }
.selector { property: <value> <value>; }
.selector { property: <value> <value> <value> <value>; }
and so on...</code></pre>
</section>
<section>
<h3>{π}</h3>
<p>Value occurs π times, multiple values are space-separated</p>
<code class="alt" style="display:inline-block;"><'property-name'> = <value>{2}</code><p>↓</p><pre><code>.selector { property: <value> <value>; }</code></pre>
</section>
<section>
<h3>{π, π}</h3>
<p>Value occurs at least π times, at most π times, multiple values are space-separated</p>
<code class="alt" style="display:inline-block;"><'property-name'> = <value>{1,3}</code><p>↓</p><pre><code>.selector { property: <value>; }
.selector { property: <value> <value>; }
.selector { property: <value> <value> <value>; }</code></pre>
</section>
<section>
<h3>{π,}</h3>
<p>Value occurs at least π times, no maximum limit, multiple values are space-separated</p>
<code class="alt" style="display:inline-block;"><'property-name'> = <value>{1,}</code><p>↓</p><pre><code>.selector { property: <value>; }
.selector { property: <value> <value> <value>; }
and so on...</code></pre>
</section>
<section>
<h3>#</h3>
<p>Value occurs 1 or many times, multiple values are comma-separated</p>
<code class="alt" style="display:inline-block;"><'property-name'> = <value>#</code><p>↓</p><pre><code>.selector { property: <value>; }
.selector { property: <value>, <value>; }
.selector { property: <value>, <value>, <value>, <value>; }
and so on...</code></pre>
</section>
<section>
<h3>[ ]!</h3>
<p>Values in grouping are required, at least 1 value must occur</p>
<code class="alt" style="display:inline-block;"><'property-name'> = <value1> [ <value2> | <value3> ]!</code><p>↓</p><pre><code>.selector { property: <value1> <value2>; }
.selector { property: <value1> <value3>; }</code></pre>
</section>
</section>
<section>
<section>
<h2>Convolusion Max</h2>
</section>
<section>
<h3>box-shadow</h3>
<code class="alt">none | <shadow>#</code>
<div class="fragment">
<p>where</p>
<p><code class="alt"><shadow> = inset? && <length>{2,4} && <color>?</code></p>
</div>
<ul>
<li class="fragment">all 3 values must occur, in any order</li>
<li class="fragment">inset is optional</li>
<li class="fragment">at least 2 length values, at most 4</li>
<li class="fragment">color value is optional</li>
<li class="fragment">entire set can occur multiple times, comma-separated</li>
</ul>
</section>
<section>
<h3>background</h3>
<code class="alt"><bg-layer># , <final-bg-layer></code>
<div class="fragment">
<p>where</p>
<p><code class="alt"><bg-layer> = <bg-image> || <position> [ / <bg-size> ]? || <repeat-style> || <attachment> || <box> || <box></code>
<code class="alt"><final-bg-layer> = <'background-color'> || <bg-image> || <position> [ / <bg-size> ]? || <repeat-style> || <attachment> || <box> || <box></code></p>
</div>
<ul>
<li class="fragment">at least 1 value must occur, the rest can OTOT</li>
<li class="fragment">for <position>, can optionally include <bg-size></li>
<li class="fragment">entire set for <bg-layer> can occur multiple times, comma-separated</li>
<li class="fragment">only <final-bg-layer> can have <'background-color'></li>
</ul>
</section>
<section>
<h3>grid-template-columns / grid-template-rows</h3>
<code class="alt">none | <track-list> | <auto-track-list></code>
<div class="fragment">
<p>where</p>
<pre style="font-size:85%"><code><track-list> = [ <line-names>? [ <track-size> | <track-repeat> ] ]+ <line-names>?
<auto-track-list> = [ <line-names>? [ <fixed-size> | <fixed-repeat> ] ]* <line-names>? <auto-repeat>
[ <line-names>? [ <fixed-size> | <fixed-repeat> ] ]* <line-names>?
<explicit-track-list> = [ <line-names>? <track-size> ]+ <line-names>?
<track-size> = <track-breadth> | minmax( <inflexible-breadth> , <track-breadth> ) | fit-content( <length-percentage> )
<fixed-size> = <fixed-breadth> | minmax( <fixed-breadth> , <track-breadth> ) | minmax( <inflexible-breadth> , <fixed-breadth> )
<track-breadth> = <length-percentage> | <flex> | min-content | max-content | auto
<inflexible-breadth> = <length-percentage> | min-content | max-content | auto
<fixed-breadth> = <length-percentage>
<line-names> = '[' <custom-ident>* ']'</code></pre>
<p class="fragment"><span class="emoji" role="img" tabindex="0" aria-label="person shrugging">🤷</span> I is troll <span class="emoji" role="img" tabindex="0" aria-label="smiling face with horns">😈</span></p>
</section>
</section>
<section>
<h2>Here's a <a href="https://www.chenhuijing.com/css-property-syntax/">cheatsheet</a>, you can print it.</h2>
<img data-src="img/qr.jpg" alt="qr code">
</section>
<section>
<h2>Further reading</h2>
<ul>
<li>
<a href="https://www.w3.org/TR/css3-values/#value-defs">CSS Value Definition Syntax</a>
</li>
<li>
<a href="https://www.w3.org/Style/CSS/read.en.html">Understanding the CSS Specifications</a> by <a href="http://fantasai.inkedblade.net/">Elika Etemad</a>
</li>
<li>
<a href="https://alistapart.com/article/readspec">How to Read W3C Specs</a> by <a href="http://catcode.com/">J. David Eisenberg</a>
</li>
<li>
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Reference">CSS reference</a> by <a href="https://developer.mozilla.org/en-US/">MDN</a>
</li>
<li>
<a href="https://www.smashingmagazine.com/2016/05/understanding-the-css-property-value-syntax/">Understanding The CSS Property Value Syntax</a> by <a href="http://maxdesign.com.au/about/russweakley/">Russ Weakley</a>
</li>
</ul>
</section>
<section style="text-align: left;">
<h1>THE END</h1>
<p><img class="j-icon plain" data-src="img/home.png" alt="Website"><a href="https://www.chenhuijing.com">https://www.chenhuijing.com</a></p>
<p><img class="j-icon plain" data-src="img/twitter.png" alt="Twitter"><a href="https://twitter.com/hj_chen">@hj_chen</a></p>
<p><img class="j-icon plain" data-src="img/medium.png" alt="Medium"><a href="https://medium.com/@hj_chen">@hj_chen</a></p>
<p><img class="j-icon plain" data-src="img/codepen.png" alt="Codepen"><a href="http://codepen.io/huijing/">@huijing</a></p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
history: true,
// More info https://github.com/hakimel/reveal.js#dependencies
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
</body>
</html>