-
Notifications
You must be signed in to change notification settings - Fork 83
/
part_01_selectors.html
793 lines (676 loc) · 22.9 KB
/
part_01_selectors.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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
<!doctype html>
<html>
<head>
<!--[if gte IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<![endif]-->
<!--[if lt IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1" />
<![endif]-->
<meta charset="utf-8" />
<title>CSS3: From Knowledgable to Ninja</title>
<!--<script>
document.location.href = '../selectors/index.html'
</script>-->
<link href='http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="css/screen.css" media="projection, screen"/>
<link rel="stylesheet" href="css/print.css" media="print"/>
<style>
body, #presentation, #slides {
-webkit-transition: all 1.5s linear;
-moz-transition: all 1.5s linear;
-ms-transition: all 1.5s linear;
-o-transition: all 1.5s linear;
transition: all 1.5s linear;
}
/* CSS for Structural Selector Slide */
.structural tr:first-child,
.structural tr:last-child {
font-weight: bold;
}
.structural tr:nth-child(even) {
background-color: #CCC;
}
.structural tr:nth-child(3) {
color: #CCC;
}
.structural tr:first-of-type,
.structural tr:last-of-type{
text-decoration:line-through;
}
.structural tr:nth-of-type(odd) {
background-color: #FFF;
}
.structural tr:nth-of-type(4n) {
color: #C61800;
}
.structural tr:nth-of-type(3n-1) {
font-style: italic;
}
/* SELECTION SLIDE */
.thisSlide *::selection {
background-color: #C61800;
color: #ffffff;
}
p.firstletter {width: 400px;
font-size: 24px;
font-family:Georgia, "Times New Roman", Times, serif;
margin: 0 20px 20px;
}
.firstletter::first-letter {
position: relative;
top: 8px;
float: left;
font-size: 3em;
line-height: 1;
color: #C7573A;
padding: 0 4px 2px 0;
font-weight: bold;
}
.count li {display: inline-block; text-align:center;}
.count li:nth-of-type(even) {background-color: white;}
.count li:nth-of-type(odd){background-color: #C7573A;}
.count li:first-of-type:last-of-type{width: 100%;}
.count li:nth-of-type(1):nth-last-of-type(2),
.count li:nth-of-type(2):nth-last-of-type(1){width: 50%;}
.count li:nth-of-type(1):nth-last-of-type(3),
.count li:nth-of-type(3):nth-last-of-type(1),
.count li:nth-of-type(2):nth-last-of-type(2){width: 33.33%;}
.count li:nth-of-type(1):nth-last-of-type(4),
.count li:nth-of-type(2):nth-last-of-type(3),
.count li:nth-of-type(3):nth-last-of-type(2),
.count li:nth-of-type(4):nth-last-of-type(1){width: 25%;}
input[type=checkbox]:checked + label {
color: red;
}
input:valid { border: 1px solid green;}
input:invalid { border: 1px solid red;}
input:required {border-width: 5px;}
input:optional {border-width: 10px;}
input:out-of-range { background-color: pink;}
input:in-range { background-color:lightgreen;}
/* brown: C7573A;*/
</style>
</head>
<body>
<div id="topinfo">
</div>
<div id="info">
<p>
<span class="key">→</span> and <span class="key">→</span> to change slides.
<span class="key">2</span> for comments. <a href="http://estelle.github.com/CSS-Workshop">estelle.github.com/CSS-Workshop</a>
</p>
</div>
<div id="presentation">
<div id="presentation-counter"></div>
<div id="slides">
<!-- Estelle -->
<div class="slide normal">
<header>
<h1 style="font-size:200%;">CSS: from Knowledgable to Ninja</h1>
</header>
<section class="content">
<p> ◈ Estelle Weyl</p>
<p> ◈ <a href="http://www.twitter.com/estellevw">@estellevw</a></p><p> ◈ <a href="http://www.standardista.com">www.standardista.com</a></p>
</section>
</div>
<!-- OUTLINE -->
<div class="slide normal">
<header><h1>Course Outline</h1></header>
<section class="content">
<ol><li><a href="../selectors/">Selectors</a></li>
<li><a href="part_02_specificity.html">Specificity</a></li>
<li><a href="part_03_generated.html">Generated Content</a></li>
<li><a href="part_04_media.html">Media Queries</a></li>
<li><a href="part_04_media.html#slide10">Debugging</a></li>
<li><a href="part_06_colors.html">Colors & Transparency </a></li>
<li><a href="part_07_fonts.html">Fonts / Typography </a></li>
<li><a href="part_08_backgrounds.html">Backgrounds & Borders </a></li>
<li><a href="../gradients/">Gradients</a></li>
<li><a href="part_10_transforms.html">Transforms</a></li>
<li><a href="../animation/">Transitions & Animation</a></li>
<li><a href="part_12_features.html">Other Features</a></li>
</ol>
</section>
</div>
<!-- Basic Selectors-->
<div class="slide normal light" id="slcElement">
<header><h1>Basic Selectors</h1></header>
<section class="content">
<pre contenteditable style="font-size:100%; line-height:1.5"><ul>
<li id="myID" class="myClass">item 1</li>
<li class="myClass">item 2</li>
<li>item 3</li>
</ul> </pre>
<dl class="inline">
<dt><b class="imp">#</b>myID</dt>
<dd>ID</dd>
<dt><b class="imp">.</b>myClass</dt>
<dd>class</dd>
<dt class="imp">li</dt>
<dd>tag name</dd>
</dl>
</section>
</div>
<!-- Relational selectors -->
<div class="slide normal" id="slcRelational">
<header><h1>Relational selectors</h1></header>
<section class="content">
<div class="ex right">
<ol>
<li>item 1</li>
<li>item 2</li>
<li>item 3
<ul>
<li>item a</li>
<li>item b</li>
<li>item c</li>
</ul>
</li>
<li>item 4</li>
<li>item 5</li>
<li>item 6</li>
<li>item 7</li>
</ol>
</div>
<dl>
<dt>ul li</dt>
<dd>descendant selector<br />
matches nested <li>s</dd>
<dt>ol > li</dt>
<dd><em>child selector</em> <br />
matches <li>s in <ol> but not nested <ul></dd>
<dt>li.myClass + li</dt>
<dd><em>adjacent sibling</em> </dd>
<dt><strong class="new">NEW </strong><span style="background-color:#eee; padding:3px 8px; position:relative; left: 20px; margin-left: -20px;">(IE7+)</span><br />
li.myClass ~ li</dt>
<dd>
<em>general sibling selector</em><br />
matches later siblings, but not nested.</dd>
</dl>
<p><a href="files/00_basic.html" target="play">Try it out</a></p>
</section>
</div>
<!-- Selector list -->
<div class="slide normal">
<header><h1>Lots 'o Selectors</h1></header>
<section class="content">
<ul class="columns">
<li>*</li>
<li>E</li>
<li>.class</li>
<li>#id</li>
<li>E F</li>
<li>E > F</li>
<li>E + F</li>
<li>E[attribute]</li>
<li>E[attribute=value]</li>
<li>E[attribute~=value]</li>
<li>E[attribute|=value]</li>
<li>:first-child</li>
<li>:lang()</li>
<li>:before</li>
<li>::before</li>
<li>::selection</li>
<li>:after</li>
<li>::after</li>
<li>:first-letter</li>
<li>::first-letter</li>
<li>:first-line</li>
<li>::first-line</li>
<li>E[attribute^=value]</li>
<li>E[attribute$=value]</li>
<li>E[attribute*=value]</li>
<li>E ~ F</li>
<li>:root</li>
<li>:last-child</li>
<li>:only-child</li>
<li>:nth-child()</li>
<li>:nth-last-child()</li>
<li>:first-of-type</li>
<li>:last-of-type</li>
<li>:only-of-type</li>
<li>:nth-of-type()</li>
<li>:nth-last-of-type()</li>
<li>:empty</li>
<li>:not()</li>
<li>:target</li>
<li>:enabled</li>
<li>:disabled</li>
<li>:checked</li>
<li>:indeterminate</li>
<li>:default</li>
<li>:valid</li>
<li>:invalid</li>
<li>:in-range</li>
<li>:out-of-range</li>
<li>:required</li>
<li>:optional</li>
<li>:read-only</li>
<li>:read-write</li>
</ul>
</section>
</div>
<!-- Standardista: selector support grid -->
<div class="slide" style="padding: 0;">
<object data="http://www.standardista.com/css3/css3-selector-browser-support/" style="width:100%; height:100%;"></object> </div>
<!-- Attribute selectors-->
<div class="slide normal">
<header><h1>Attribute selectors</h1></header>
<section class="content">
<dl>
<dt>element[attribute]</dt>
<dd>Select elements containing the named attribute</dd>
</dl>
<pre contenteditable style="font-size: 95%;"><strong>img[alt] {}</strong>
<img src="image.jpg" <strong>alt</strong>="accessible">
<span style="opacity:0.3"><img src="image.jpg" title="inaccessible"></span>
<strong>form [type] {}</strong>
<input <strong>type</strong>=date>
<span style="opacity:0.3"><select></span></pre>
<p><small>IE6 sucks <br />
IE7 support basic non-empty attribute</small></p>
</section>
</div>
<!-- Older attribute selectors -->
<div class="slide normal">
<header style="position:absolute; top: 20px; right: 20px;"><h1>Older attribute selectors</h1></header>
<section class="content">
<dl>
<dt>E[attr]</dt>
<dd>Element E that has the attribute attr with any value.</dd>
<dt>E[attr="val"]</dt>
<dd>Element E that has the attribute attr with the exact, case-sensitive if attribute is case sensitive, value <em>val</em>.</dd>
<dt>E[attr|=val]</dt>
<dd>Element E whose attribute <em>attr</em> has a value <em>val</em> or begins with val- ("val" plus "-").<br />
<pre contenteditable>p[lang|="en"]{/* <p lang="en-us"> <p lang="en-uk"> */ }</pre>
</dd>
<dt>E[attr~=val]</dt>
<dd>Element E whose attribute <em>attr</em> has within its value the space-separated full word <em>val</em>.<br />
<pre contenteditable>a[title~=more] {/* <a title="want more info about this?">}</pre>
</dd></dl>
</section>
</div>
<!-- CSS3 Attribute Selectors -->
<div class="slide normal">
<header style="position:absolute; top: 20px; right: 20px;"><h1>CSS3 Attribute Selectors</h1></header>
<section class="content">
<dl>
<dt>E[attr^=val]</dt>
<dd>Element E whose attribute <em>attr</em> starts with the value <em>val</em>.<br />
<pre contenteditable>a[href^=mailto] {background-image: url(emailicon.gif);}
a[href^=http]:after {content: " (" attr(href) ")";}</pre>
</dd>
<dt>E[attr$=val]</dt>
<dd>Element E whose attribute <em>attr</em> ends in <em>val</em> . <br />
<pre contenteditable>a[href$=pdf] {background-image: url(pdficon.gif);}
a[href$=pdf]:after {content: " (PDF)";}</pre>
</dd>
<dt>E[attr*=val]</dt>
<dd>Element E whose attribute <em>attr </em>matches <em>val</em> anywhere within the attribute. Similar to E[attr~=val] above, except the <em>val</em> can be part of a word.</dd>
</dl>
<p>Note: Multiple attributes work! a[title][href]</p>
</section>
</div>
<!-- Attribute Selectors Recap -->
<div class="slide normal">
<header><h1>Attribute Selectors Recap</h1></header>
<section class="content">
<pre contenteditable style="float:left; width: 45%; margin: 0 20px 0 0;">
input[placeholder] {
<b class="notes">/* matches any input with a placeholder */</b>}
input[type=email] {
<b class="notes">/* exact match */</b>}
abbr[title~=unicorn] {
<b class="notes">/* matches unicorn but not unicorns */</b>}
abbr[title|=en] {
<b class="notes">/* matches en-us and en-uk */</b>}
a[href^=mailto] {
<b class="notes">/* starts with */</b>}
a[href$=pdf]{
<b class="notes">/* ends in */</b>}
abbr[title*=unicorn] {
<b class="notes">/* matches unicorn and unicorns */</b>}
</pre>
<pre contenteditable style="float:left; width: 40%; margin-top:0;">E:[att] <b class="notes"><br/>/* have the attribute at all */</b>
E:[att=val] <b class="notes"><br/>/* exact */</b>
E:[att~=val] <b class="notes"><br/>/* val is a space separated word */</b>
E:[att|=val] <b class="notes"><br/>/* with a dash */</b>
E:[att^=val] <b class="notes"><br/>/* begins with val */</b>
E:[att$=val] <b class="notes"><br/>/* ends with val */</b>
E:[att*=val] <b class="notes"><br/>/* val is anywhere as a substring */</b>
.</pre>
<pre contenteditable style="clear:both">
@media print{
abbr[title]:after {
content: "(" attr(title) ")";
}
a[href^=http]:after {
content: "(" attr(href) ")";
}
}</pre>
</section>
</div>
<!-- Using attribute selectors -->
<div class="slide normal">
<header><h1>Using attribute selectors</h1></header>
<section class="content play">
<h1><a href="files/01_attr.html" target="play">Play Time: Attribute Selectors</a></h1>
<p><strong>Note:</strong> The top line of the example is editable. The CSS will impact the contents on the rest of the page.</p>
</section>
</div>
<!-- UI pseudo-classes -->
<div class="slide normal">
<header><h1>UI pseudo-classes</h1></header>
<section class="content">
<p>Based on current state of UI</p>
<pre contenteditable>
:enabled
:disabled
:checked
</pre>
<p style="float: left; margin-right:20px">Example:<p>
<pre contenteditable style="float: left">input[type=checkbox]:checked + label {
color: red;
}</pre>
<div style="clear:both;">
<input type="checkbox" id="test1ck"/> <label for="test1ck">Check and Uncheck Me</label><br/>
<input type="checkbox" id="test2ck"/> <label for="test2ck">Check and uncheck me too!</label></div> </section>
</div>
<!--Form related UI pseudo-classes -->
<div class="slide normal">
<header><h1>Form related UI pseudo-classes</h1></header>
<section class="content">
<pre contenteditable class="columns2">:valid
:invalid
:required
:optional
:in-range
:out-of-range
:read-only
:read-write
:default</pre>
<p style="float: left; margin-right:20px">Example:<p>
<pre contenteditable style="float: left">input:valid { border: 1px solid green;}
input:invalid { border: 1px solid red;}
input:required {border-width: 5px;}
input:optional {border-width: 10px;}
input:out-of-range { background-color: pink;}
input:in-range { background-color:lightgreen;}</pre>
<div style="clear:both;">
<input type="number" min="5" max="7" id="test3ck" required/> <label for="test3ck">Number between 5 and 7</label><br/>
<input type="color" pattern="#[a-fA-F0-9]{6}" id="test4ck" /> <label for="test4ck">Hexidecimal color</label>
</div> </section>
</div>
<!-- UI selectors -->
<div class="slide normal">
<header><h1>UI selectors</h1></header>
<section class="content play">
<h1><a href="files/02_uiselectors.html" target="play">Play Time: UI Selectors</a></h1>
<p>Test them out for yourselves</p>
</section>
</div>
<!-- List of Structural selectors -->
<div class="slide normal">
<header><h1>Structural selectors</h1></header>
<section class="content">
<pre contenteditable class="columns2">:nth-child()
:nth-last-child()
:nth-of-type()
:nth-last-of-type()
:first-child<sup style="color:#C61800">*</sup>
:last-child
:first-of-type
:last-of-type
:only-child
:only-of-type
:root
:empty
:not(:empty)
</pre>
<ul><li>Target elements on the page based on their relationships to other elements in the DOM.</li>
<li>Updates dynamically if page updates.</li>
<li>Reduced need for extra markup, classes and IDs</li>
</ul>
<small style="position:absolute; bottom: 10px; right: 10px;"><sup style="color:#C61800">*</sup> CSS2 / IE8 </small>
</section>
</div>
<!--First, last, & only -->
<div class="slide normal">
<header><h1>First, last, & only</h1></header>
<section class="content">
<pre contenteditable>
:first-child
:last-child
:first-of-type
:last-of-type
:only-child
:only-of-type
</pre>
<p>Easier to explain <a href="files/04_firstlastonly.html" target="play">by example</a></p>
</section>
</div>
<!--nth pseudo-classes -->
<div class="slide normal">
<header><h1>nth pseudo-classes</h1></header>
<section class="content">
<pre contenteditable>:nth-child(<b>3n</b>)
:nth-last-child(<b>odd</b>)
:nth-of-type(<b>5</b>)
:nth-last-of-type(<b>3n+1</b>) </pre>
<p>Target element or elements based on argument passed to the selector</p>
<ul class="pre">
<li>:nth-of-type(<b>even</b>)</li>
<li>:nth-of-type(<b>odd</b>)</li>
<li>:nth-of-type(<b>an+b</b>) </li>
</ul>
<p><a href="files/05_nth.html" target="play">Let's Play</a> <small style="float:right">Note: Play with negative values for 'a'</small></p>
</section>
</div>
<!--Structural Selectors -->
<div class="slide normal">
<header><h1>Structural Selectors</h1></header>
<section class="content">
<pre contenteditable style="margin-top: 0; float: left;">
tr:<b>first-child</b>,
tr:<b>last-child</b> {
font-weight: bold;
}
tr:<b>first-of-type</b>,
tr:<b>last-of-type</b>{
text-decoration:line-through;
}
tr:<b>nth-child</b>(<b>even</b>) {
background-color: #CCC;
}
tr:nth-child(<b>3</b>) {
color: #CCC;
}
tr:<b>nth-of-type</b>(<b>odd</b>) {
background-color: #FFF;
}
tr:nth-of-type(<b>4n</b>) {
color: #C61800;
}
tr:nth-of-type(<b>3n-1</b>) {
font-style: italic;
}
</pre>
<table class="structural" cellpadding="1" cellspacing="0" border="0" style="float: right; width:33%;">
<tbody>
<tr><td>Row 1</td></tr>
<tr><td>Row 2</td></tr>
<tr><td>Row 3</td></tr>
<tr><td>Row 4</td></tr>
<tr><td>Row 5</td></tr>
<tr><td>Row 6</td></tr>
<tr><td>Row 7</td></tr>
<tr><td>Row 8</td></tr>
<tr><td>Row 9</td></tr>
<tr><td>Row 10</td></tr>
</tbody>
</table>
</section>
</div>
<!--Advanced Structural Selectors -->
<div class="slide normal">
<header><h1>Structural Selectors</h1></header>
<section class="content">
<ul class="count"><li>1</li></ul>
<ul class="count"><li>1</li><li>2</li></ul>
<ul class="count"><li>1</li><li>2</li><li>3</li></ul>
<ul class="count"><li>1</li><li>2</li><li>3</li><li>4</li></ul>
<pre contenteditable> li:first-of-type:last-of-type{width: 100%;}
li:nth-of-type(1):nth-last-of-type(2),
li:nth-of-type(2):nth-last-of-type(1){width: 50%;}
li:nth-of-type(1):nth-last-of-type(3),
li:nth-of-type(3):nth-last-of-type(1),
li:nth-of-type(2):nth-last-of-type(2){width: 33.33%;}
li:nth-of-type(1):nth-last-of-type(4),
li:nth-of-type(2):nth-last-of-type(3),
li:nth-of-type(3):nth-last-of-type(2),
li:nth-of-type(4):nth-last-of-type(1){width: 25%;}</pre>
</section>
</div>
<!-- :empty pseudo-class -->
<div class="slide normal">
<header><h1>:empty pseudo-class </h1></header>
<section class="content">
<pre contenteditable>p<strong>:empty</strong> {
/* styles here */
}
</pre>
<p>Matches:
<pre contenteditable><p></p>
<p><!-- this is a comment --></p>
</pre>
</section>
</div>
<!-- :not -->
<div class="slide normal">
<header><h1><strong>:not</strong> - Negation pseudo-class</h1></header>
<section class="content">
<pre contenteditable>
<span class="hilite" style="background-color:#ededed">div</span><span class="hilite" style="background-color:#deded8">:not(</span><span class="hilite" style="background-color:#f9f9f9">.excludeMe</span><span class="hilite" style="background-color:#deded8">)</span></pre>
</pre>
<p><a href="files/06_not.html" target="play">Practice makes perfect</a></p>
</section>
</div>
<!-- lang, target, anchor links-->
<div class="slide normal">
<header><h1>Other Pseudo Classes</h1></header>
<section class="content">
<pre contenteditable>
:lang
:target
</pre>
<p>link & user action pseudo-classes</p>
<pre contenteditable>
:link
:visited
:hover
:active
:focus
</pre>
<p> <a href="files/07_target.html" target="play">:target</a> example</p>
</section>
</div>
<!--root -->
<div class="slide normal">
<header><h1>:root</h1></header>
<section class="content">
<pre contenteditable>
:root
</pre>
<p>Selects the document root, which is <html></p>
<ul><li>Declare <em>font-size</em> on <strong>:root</strong> if using <strong>rem</strong> units</li>
<li>Style <strong>:root</strong> only if showing <strong><head></strong> (as in our exercise files)</li>
<li>In CSS4, define Defining Variables on root. (see <a href="http://dev.w3.org/csswg/css-variables/" target="play">Variables module</a>)</li>
</ul>
<p><small><a href="files/03_root.html" target="play">example</a></small></p>
</section>
</div>
<!-- Pseudo elements -->
<div class="slide intro">
<header><h1>Pseudo elements</h1></header>
</div>
<!-- Pseudo elements -->
<div class="slide normal thisSlide">
<header><h1>Pseudo elements</h1></header>
<section class="content">
<pre contenteditable style="font-size: 100%;">
::first-line
::first-letter
::selection (not in specification)
::before
::after
</pre>
<p><i class="imp">Pseudo-classes</i> select elements that
already exist.<br>
<i class="imp">Pseudo-elements</i> create "faux" elements you can style.</p>
<p> Use single colon because of IE</p>
</section>
</div>
<!-- Drop Cap -->
<div class="slide normal ">
<header><h1>::first-letter</h1></header>
<section class="content">
<p class="firstletter">You can even pretty drop-caps with :first-letter, but make sure to apply it to p:first-of-type so your site not too ugly. <a href="files/08_dropcap.html" target="play">Code for drop cap.</a></p> <pre contenteditable>p:first-of-type::first-letter {
position: relative;
top: 8px;
float: left;
font-size: 3em;
line-height: 1;
color: #C7573A;
padding: 0 4px 2px 0;
font-weight: bold;
}
</pre>
</section>
</div>
<!-- ::selection -->
<div class="slide normal thisSlide">
<header><h1>::selection</h1></header>
<section class="content">
<pre contenteditable>.thisSlide *::selection {
background-color: #C61800;
color: #ffffff;
}
</pre>
<p class="notes">Prefix with -moz- for Firefox<br>
Use single colon because of IE</p>
</section>
</div>
<!-- selectors tips -->
<div class="slide normal">
<header><h1>Tips</h1></header>
<section class="content">
<ul>
<li><a href="http://selectivizr.com/" target="_blank">selectivizr.com</a> + JS Library = JS for backward compatibility</li>
<li>jQuery $(selector) == document.querySelectorAll(selector)</li>
<li>Many, many more pseudo-elements with prefixes currently treated as a shadow DOM
<ul><li>::-webkit-progress-bar</li>
<li>::-webkit-progress-value</li>
<li>::-webkit-meter-even-less-good-value
</li>
<li>::-webkit-inner-spin-button /outer-spin-button
</li>
<li>::-webkit-validation-bubble / arrow-clipper /arrow /message</li>
<li>::-webkit-scrollbar</li>
<li>::-webkit-scrollbar-button / thumb / track
<li><a href="https://developer.mozilla.org/en/CSS_Reference/Mozilla_Extensions#section_22" target="_new">Mozilla Pseudo-elements and pseudo-classes</a></li>
</ul>
</li>
</ul>
</section>
</div>
<!-- -->
<div class="slide intro">
<header><h1>Specificity </h1></header>
<section class="content">
<h1><a href="part_02_specificity.html#slide3">Next ➹</a></h1>
</section>
</div>
</div>
<script src="css/slide.js"></script>
</body>
</html>