forked from hakimel/reveal.js
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcss-training-2023-half-day.html
3011 lines (2798 loc) · 103 KB
/
css-training-2023-half-day.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
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CSS Training</title>
<meta name="description" content="Half day CSS training">
<meta name="author" content="Wes Ruvalcaba">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="dist/reset.css">
<link rel="stylesheet" href="dist/reveal.css">
<link rel="stylesheet" href="plugin/prism/prism.css">
<link rel="stylesheet" href="plugin/fontawesome/css/font-awesome.min.css">
<link rel="stylesheet" href="css/theme/wes-light.css" id="theme">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
<style>
code {
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
}
.section-indicator {
position: absolute;
top: 0;
right: 0;
z-index: -1;
font-size: 0.6em;
transform: skew(-10deg);
}
.section-indicator:before {
content: '';
position: absolute;
top: -0.5em;
bottom: -0.5em;
left: -0.75em;
right: -2em;
z-index: -1;
background: rgba(35, 165, 216, 0.2);
}
section {
text-align: left;
}
</style>
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section >
<p class="small" style="position: relative; top: -6em;"><strong>Pro-tip:</strong> Press <span style="display: inline-block; padding: .2em .6em; border: 1px solid #777; border-radius: .3em; background: #fff; box-shadow: 0 1px 0 #555, 0 2px 0 #555, 0 3px 0 #555, 0 4px 0 #555; position: relative; top: -.1em; color: #000;">space bar</span> to progress and it won't skip any slides</p>
<h1>
CSS in 2023
</h1>
<p>Layout, Variables, Organization, and more.</p>
</section>
<section>
<section style="position: relative">
<div style="
position: absolute;
top: 0;
right: 0;
width: 38%;
height: 100%;
overflow: hidden;
background: url(assets/me.jpg) no-repeat 45% 50%;
background-size: cover;
">
</div>
<div style="box-sizing: border-box; width: calc(65% - 0.6em);">
<h3 id="wes-ruvalcaba">Wes Ruvalcaba</h3>
<ul style="font-size: 0.8em">
<li>Principal Software Engineer at Red Hat</li>
<li>Writing CSS since 2002</li>
<li>Markup, CSS & Standards Dork</li>
<li>Tend to write custom code, more than repurpose existing</li>
</ul>
</div>
<p style="margin-top: 1em;"><a href="https://tech.lgbt/@wesruv">tech.lgbt/@wesruv</a></p>
</section>
<section>
<h3>Feel free to ask questions at any time!</h3>
</section>
</section>
<section data-background-color="#fff">
<img src="assets/redhat-logo.svg" alt="Red Hat">
</section>
<section>
<h3>People I'm Stealing <em>a lot</em> from</h3>
<ul>
<li>Rachel Andrew</li>
<li>Chris Coyier</li>
<li>Kevin Powell</li>
<li>Jen Simmons</li>
<li>Mozilla Developer Network</li>
<li>... and plenty of others (see sources slides)</li>
</ul>
</section>
<section>
<h3>The Goal</h3>
<aside class="notes">
<p>Kinda good at CSS to understanding the harder concepts of CSS.</p>
<p>Understand the tools available, how they work, and what they're good at.</p>
</aside>
</section>
<section>
<h2 id="well-go-over">We'll go over</h2>
<ul style="font-size: 0.9em; width: 100%; padding: 0;">
<li>CSS "Units" and "Lengths"</li>
<li>Media Queries</li>
<li>Layout with CSS post Grid & Flexbox</li>
<li>Advanced styling techniques & animating</li>
<li>Accessibility</li>
<li>Debugging CSS Issues</li>
<li>Architecting CSS</li>
<li>Fancy Tips and Tricks</li>
</ul>
</section>
<section class="center">
<section>
<h2 id="foreword">Foreword Advice</h2>
</section>
<section data-background="assets/css-training/walnut-brain.jpg">
<aside class="notes">You don't need to memorize everything</aside>
</section>
<section data-background="assets/css-training/write-css-code.jpg">
<aside class="notes">
Make excuses to use, practice, or teach CSS
</aside>
</section>
<section data-background="#fff" style="text-align: center;">
<img src="assets/css-training/read-the-docs.png" style="width: 70%" alt="" />
<aside class="notes">
Read the (W3C) docs, or if those are imparsible nonsense (it happens), look it up on MDN or CSS Tricks
</aside>
</section>
<section data-background="#fff" style="text-align: center;">
<img src="assets/css-training/w3c-not-w3c-schools.png" style="width: 100%" alt="" />
<aside class="notes">
W3C schools is not associated with the W3C,<br>
I loathe their site, and their docs are crap
</aside>
</section>
</section>
<section>
<p>Prologue</p>
<h2>Debugging Tool Basics</h2>
<a href="assets/css-training/sample-page.html" target="css-training">Sample page</a>
<aside class="notes">
- Inspect<br>
- Style pane<br>
- Calculated pane<br>
- Layout Pane<br>
- Grid Inspector
</aside>
</section>
<section>
<section>
<p>Part 1</p>
<h2 id="units-lengths">Helpful Units and Lengths</h2>
</section>
</section>
<section>
<h3>Text Based Units</h3>
</section>
<section>
<div class="section-indicator">Units and Lengths</div>
<section>
<h4><code>em</code></h4>
<div style="padding: 1em 0;">
<p>
<code>1em</code> = Calculated <code>font-size</code> of current element
</p>
</div>
<aside class="notes">
This may be confusing for some of you, because it has <em>nothing</em> to do with the width of an "em dash".
Draw out calculation examples.
</aside>
<pre class="language-css"><code class="language-css">1em
1.25em
3em</code></pre>
</section>
<section>
<div class="column-wrapper">
<pre class="language-css" style="max-width: 50%;"><code class="language-css">.box {
width: 2em;
background: deepskyblue;
}
.box-2 {
font-size: 2em;
width: 2em;
background: palegreen;
}</code></pre>
<div style="padding: 1em;">
<div style="width: 2em; background: deepskyblue;">
<code style="border: 0; background: transparent; margin: 0; padding: 0;">.box</code>
</div>
<div style="width: 2em; font-size: 2em; background: palegreen;">
<code style="border: 0; background: transparent; margin: 0; padding: 0; white-space: nowrap;">.box-2</code>
</div>
</div>
</div>
<aside class="notes">Before why, note that despite font size, bars line up</aside>
</section>
</section>
<section>
<div class="section-indicator">Units and Lengths</div>
<section>
<pre class="language-css"><code class="language-css">.box {
/* font-size: 16px; (default) */
width: 2em; /* 2em = 16px * 2 = 32px */
background: deepskyblue;
}
.box-2 {
font-size: 2em; /* 2em = 16px * 2 = 32px */
/* The 32px font-size will then change what
2em on the width means */
width: 2em; /* 2em = 32px * 2 = 64px */
background: palegreen;
}</code></pre>
</section>
</section>
<section>
<div class="section-indicator">Units and Lengths</div>
<section>
<h4><code>rem</code></h4>
<div style="padding: 1em 0;">
<p>
<code>1rem</code> = Calculated <code>font-size</code> of <code>html</code> element
</p>
</div>
<pre class="language-css"><code class="language-css">1rem
1.25rem
3rem</code></pre>
<aside class="notes">
rem stands for Root em, so no matter where you are in the document, 1rem will come out the same<br>
</aside>
</section>
<section>
<div class="column-wrapper">
<pre class="language-css" style="max-width: 50%;"><code class="language-css">.box {
width: 2rem;
background: deepskyblue;
}
.box-2 {
font-size: 2rem;
width: 2rem;
background: palegreen;
}</code></pre>
<div style="padding: 1em;">
<div style="width: 2rem; background: deepskyblue;">
<code style="border: 0; background: transparent; margin: 0; padding: 0;">.box</code>
</div>
<div style="width: 2rem; font-size: 2em; background: palegreen;">
<code style="border: 0; background: transparent; margin: 0; padding: 0; white-space: nowrap;">.box-2</code>
</div>
</div>
</div>
<aside class="notes">
While you <em>can</em> change the font size of html, I recommend you don't and use body instead.<br>
I use rem instead of pixels, it prevents breakage if the browser has an increased font size
</aside>
</section>
</section>
<section>
<div class="section-indicator">Units and Lengths</div>
<section>
<h3>Viewport Units</h3>
</section>
<section>
<h4>What's a viewport?</h4>
<img src="assets/css-training/viewport-area.png" alt="Viewport Area, the size of the browser" />
</section>
</section>
<section>
<div class="section-indicator">Units and Lengths</div>
<section>
<h4 style="position: absolute;"><code>vw</code></h4>
<img src="assets/css-training/vw.png" style="width: 100%" alt="vw - percentage width of the browser window" />
</section>
<section>
<h5><code>25vw</code></h5>
<img src="assets/css-training/vw25.png" alt="25vw examples" />
</section>
</section>
<section>
<div class="section-indicator">Units and Lengths</div>
<section>
<h4 style="position: absolute;"><code>vh</code></h4>
<img src="assets/css-training/vh.png" style="width: 100%" alt="vh - percantage height of the browser window"/>
</section>
<section>
<h5><code>25vh</code></h5>
<img src="assets/css-training/vh25.png" alt="25vh examples" />
</section>
</section>
<section>
<div class="section-indicator">Units and Lengths</div>
<h3>Physical Units</h3>
<ul>
<li><code>mm</code> millimeter</li>
<li><code>cm</code> centimeter</li>
<li><code>in</code> inch</li>
<li><code>pt</code> point</li>
<li><code>pc</code> pica</li>
</ul>
<aside class="notes">
These exist, and are most useful in print stylesheets, but I've never used them
</aside>
</section>
<section>
<div class="section-indicator">Units and Lengths</div>
<section>
<h3>Which unit should I use?</h3>
</section>
<section>
<h4>Relative Units</h4>
<style>
.button[class][class] {
display: inline-block;
padding: 0.75em 1em;
margin: 0 1em 1em 0;
background: #225378;
color: #fff;
}
.button--px[class][class] {
padding: 17px 23px;
margin: 0 23px 23px 0;
}
</style>
<p>When size should be proportionate to the unit's basis</p>
<p><strong>Sized with em</strong></p>
<div style="font-size: 0.6em">
<a href="#" target="css-training" class="button">My button</a>
<a href="#" target="css-training" class="button" style="font-size: 2em;">Larger button</a>
</div>
<p><strong>Sized with px</strong></p>
<div style="font-size: 0.6em">
<a href="#" target="css-training" class="button button--px">My button</a>
<a href="#" target="css-training" class="button button--px" style="font-size: 2em;">Larger button</a>
</div>
</section>
</section>
<section>
<h2>Media Queries</h2>
</section>
<section>
<div class="section-indicator">Media Queries</div>
<section>
<h3>Media Queries</h3>
<p>Special styles for specific circumstances</p>
<pre class="language-css"><code>@media /* Conditions */ {
/* CSS Rules */
}</code></pre>
<aside class="notes">
Ask questions about the end user's browser
</aside>
</section>
<section>
<h3>Which Medium?</h3>
<pre class="language-css"><code>@media screen { /* Computer Display CSS Rules */ }
@media print { /* Print CSS Rules */ }</code></pre>
<p><small>Fun fact: <br><code>speech</code>, <code>braille</code>, <code>embossed</code> (braille printers), <br><code>tty</code> (like command line), <code>tv</code> also exist.</small></p>
</section>
<section>
<h3>What Size?</h3>
<pre class="language-css"><code>@media (min-width: 768px) {
/* CSS Rules */
}
@media (min-width: 48em) and (min-height: 30em) {
/* CSS Rules */
}
@media (max-height: 500px) {
/* CSS Rules */
}</code></pre>
</section>
</section>
<section>
<div class="section-indicator">Media Queries</div>
<section>
<h3><code>@media</code> Best Practices</h3>
</section>
<section>
<h4>Mobile First <code>@media</code> queries</h4>
<p style="font-size: 1.25em; line-height: 1.8;">Write <code>min-width</code> and <code>min-height</code>,<br><br>
<strong>not</strong> <code>max-width</code> or <code>max-height</code></p>
</section>
<section>
<pre class="language-css"><code style="font-size: 0.85em">.box {
/* Mobile CSS */
}
@media (min-width: 48em) {
.box {
/* Decent size screen styles */
}
}
@media (min-width: 62em) {
.box {
/* Huge screen styles */
}
}
</code></pre>
<aside class="notes">
Don't write max-width/height, larger screen styles will override smaller screen styles<br>
Don't have to work mobile first, just have to end up with mobile first code.
</aside>
</section>
<section>
<h4>Group all styles for an element</h4>
<pre class="language-css"><code style="font-size: 0.9em">/* Widget Styles */
.widget { }
@media (min-width: 768px) {
.widget { }
}
/* Doo Dad Styles */
.doo-dad { }
@media (min-width: 768px) {
.doo-dad { }
}
</code></pre>
<aside class="notes">
<p>Separating styles by media query gets confusing and hard to maintain, group styles by what element.</p>
</aside>
</section>
<section>
<h4>Only be as specific as necessary</h4>
<pre class="language-css"><code style="font-size: 0.9em">
@media (min-width: 768px) and screen {
/* Is screen necessary, do we want to exclude print? */
.widget { }
}
@media (min-width: 1024px) and (min-height: 768px) {
/* Is height necessary, should 750px tall screens be excluded? */
.widget { }
}
</code></pre>
</section>
<section>
<h4>Media queries should be based on content, not devices</h4>
<ul>
<li>Are columns squished?</li>
<li>Line lengths too long or short?</li>
<li>Images need to be bigger?</li>
</ul>
<p>Devices can be a decent guide.<br>Test from 300px - 1600px wide.</p>
</section>
<section style="text-align: center;">
<img style="border: 0.25em solid #ccc;" src="assets/css-training/long-lined-content.png" alt="Bootstrap.com between mobile and tablet has long line lengths making it harder to read" width="50%" />
<aside class="notes">
GetBootstrap.com - Between mobile and tablet - long line lengths
</aside>
</section>
<section style="text-align: center;">
<p style="font-size: 0.75em">This screenshot is faked</p>
<img style="border: 0.25em solid #ccc;" src="assets/css-training/squished-column-content.png" alt="Bootstrap.com faked example of when columns might be too constrained" />
<aside class="notes">
GetBootstrap.com - Faked example where I'd adjust media queries
</aside>
</section>
</section>
<section><h1>CSS Layout</h1></section>
<section>
<section>
<h2>Document Flow & You</h2>
<aside class="notes">
Going to try and explain the intention behind CSS<br>
I'm going to take small liberties and make up some terms.
</aside>
</section>
<section>
<img src="assets/css-training/webpage.png" class="block-centered" style="width: 70%" alt="Mock up of an article page" />
<aside class="notes">
Document flow is how elements want to layout on the page, given their styles.<br>
See text flow<br>
See floated image
</aside>
</section>
<section>
<img src="assets/css-training/document-flow.png" class="block-centered" style="width: 80%" alt="Mock up of an article page" />
<aside class="notes">
This is DF<br>
They're cool<br>
Want you to be able to see all the content<br>
Read all the text<br>
Tries not to let things overlap<br>
Doesn't dig pixel perfection much<br>
Don't be mean to document flow, respecting DF pays off.
</aside>
</section>
<section data-background="assets/css-training/document-flow-bg.png" data-background-size="100% auto" data-background-position="left top">
<h3>Text Flow</h3>
<ul>
<li>How text behaves and tags like <code><strong></code> & <code><em></code></li>
<li>Inline* elements mimic text flow</li>
<li>White space matters* (*up to one space!)</li>
</ul>
<aside class="notes">
With no CSS, HTML will fall back to a textual flow<br>
Doesn’t care about widths, heights, margins, padding, etc
</aside>
</section>
<section data-background="assets/css-training/document-flow-bg.png" data-background-size="100% auto" data-background-position="left top">
<h3>Layout Flow</h3>
<ul>
<li>White space agnostic</li>
<li>Properties like:<ul>
<li>Grid</li>
<li>Flexbox</li>
<li>Table</li>
<li>CSS Columns</li>
</ul></li>
</ul>
<aside class="notes">
Composing major parts of doc<br>
The large squares/rectangles that the web is good at
</aside>
</section>
<section>
<img src="assets/css-training/webpage.png" class="block-centered" style="width: 70%" alt="Mock up of an article page" />
<aside class="notes">
Content area might be flexbox (Layout flow), but inside of the left column we go back to text flow
</aside>
</section>
<section>
<img src="assets/css-training/pos-absolute.png" class="block-centered" style="width: 80%" alt="Mock up of an article page" />
<aside class="notes">
This angry fellow represents properties that break/mess with document flow<br>
It's not wrong to break document flow, it is gutsy<br>
He'll do exactly what you say, even when it doesn't make sense<br>
Lose the safeguards of document flow that made sure content is legible<br>
He's been grumpy about all these new-fangled screen sizes<br>
Test your CSS on many screen sizes, px densities, and browsers when you bring out this guy<br>
</aside>
</section>
<section align="left" data-background="assets/css-training/pos-absolute-bg.png" data-background-size="100% auto" data-background-position="left top">
<h3 style="margin-top: 1.25em">Document Flow Breakers:</h3>
<div class="section-indicator">Document Flow</div>
<p><code>position: absolute, fixed, sticky</code></p>
<aside class="notes">
These will behave very rigidly and can cause overlap or bugs on differently sized screens.<br>
Position fixed is particularly grumpy about smaller sized screens and zooming
</aside>
</section>
<section align="left" data-background="assets/css-training/pos-absolute-bg.png" data-background-size="100% auto" data-background-position="left top">
<h3>Mess with Document Flow</h3>
<ul>
<li style="line-height: 1.8"><code>position: relative</code><br>
(when <code>top, right, bottom</code> or <code>left</code> are set)</li>
<li><code>transform</code></li>
<li>negative <code>margin</code> or <code>padding</code></li>
</ul>
<aside class="notes">
These can cause overlap and can get a little weird
</aside>
</section>
<section>
<img src="assets/css-training/webpage-modal.png" class="block-centered" style="width: 80%" alt="Mock up of an article page" />
<aside class="notes">
To get a modal like this, you have to break document flow<br>
But notice inside of it, we're back to regular document flow
</aside>
</section>
<section>
<h3>TL:Didn't think your cartoons were funny</h3>
<ul>
<li>Breaking the flow can cause complicated, hard to solve problems.</li>
<li>Try to use Flow-friendly CSS first.</li>
<li>Breaking flow isn't 'bad', but should be used sparingly and carefully.</li>
</ul>
</section>
</section>
<section>
<h2>Layout 101 in Post-CSS Grid</h2>
<aside class="notes">
We're going to start from the outside out.
</aside>
</section>
<section>
<section><h3>Floats</h3></section>
<section>
<h4>Don't use them for layout anymore*!</h4>
<p class="small" style="margin-top: 6em;">* Except for fallbacks or if you <b>know</b> better options aren't wise<br> based on your user stats.</p>
<aside class="notes">
If you can, avoid learning floats for layout, it'll go out of fashion fast<br>
They were <b>literally</b> never intended to be used for layout, we've been using CSS hacks for over a decade.
</aside>
</section>
<section align="left">
<img src="assets/css-training/document-flow.png" alt="Document flow cartoon character" style="width: 25%; float: right;" />
<h4>Are floats still good for something?</h4>
<p style="font-size: 0.75em;">Floats are great for floating elements next to a bunch of text so it will wrap. </p>
<p style="font-size: 0.5em; opacity: 0.4">Lorem ipsum dolor sit amet, wakka un blitz and chips; dolla dolla bill. Lorem ipsum dolor sit amet, wakka un flurb dolla dolla bill. Lorem ipsum dolor sit amet, wakka un flurb dolla dolla bill. Lorem ipsum dolor sit amet, wakka un blitz and chips; dolla dolla bill. Lorem ipsum dolor sit amet, wakka un flurb dolla dolla bill. Lorem ipsum dolor sit amet, wakka un flurb dolla dolla bill.</p>
<p style="font-size: 0.5em; opacity: 0.4">Lorem ipsum dolor sit amet, wakka un blitz and chips; dolla dolla bill. Lorem ipsum dolor sit amet, wakka un flurb dolla dolla bill. Lorem ipsum dolor sit amet, wakka un flurb dolla dolla bill.</p>
</section>
</section>
<section>
<div class="section-indicator">Terminology</div>
<section>
<h3>CSS Grid</h3>
<p>Basics and terminology</p>
</section>
<section>
<h4>CSS Grid</h4>
<p>Great at 2 dimensional, custom, and large scale layouts</p>
<ul>
<li>Define amount of rows and columns</li>
<li>Define constraints for rows and columns</li>
<li>Constraints can be rigid, flexible, or content based</li>
</ul>
<style>
.grid-example-wrapper {
position: relative;
transform: scale(0.9);
}
.grid-example {
position: relative;
display: grid;
width: 100%;
height: 14em;
grid-template: 1fr 1fr 1fr / 1fr 1fr 1fr;
border: 0.125em dashed rgba(0, 0, 0, 0.6);
}
.grid-example > * {
position: relative;
z-index: 1;
}
.grid-example-wrapper:before,
.grid-example-wrapper:after,
.grid-example:before,
.grid-example:after {
content: '';
position: absolute;
left: 33.333%;
top: 0;
bottom: 0;
display: block;
width: 0;
border-left: 0.125em dashed rgba(0, 0, 0, 0.3);
}
.grid-example-wrapper:before {
left: 66.667%;
}
.grid-example-wrapper:after,
.grid-example:after {
top: 33.333%;
left: 0;
right: 0;
bottom: auto;
width: auto;
height: 0;
border-top: 0.125em dashed rgba(0, 0, 0, 0.3);
border-left: 0;
}
.grid-example-wrapper:after {
top: 66%;
}
.grid-example-wrapper:before,
.grid-example-wrapper:after,
.grid-example:before,
.grid-example:after {
border-color: rgba(0, 0, 0, 0.6);
}
</style>
</section>
<section>
<h4>Grid Container</h4>
<p>Element surrounding the grid.</p>
<div class="grid-example-wrapper">
<div class="grid-example" style="border: 0.25em solid #3372a1"></div>
</div>
</section>
<section>
<h4>Grid Item</h4>
<p>Direct child element of a grid container</p>
<div class="grid-example-wrapper">
<div class="grid-example" style="font-weight: bold;">
<div style="
grid-row-start: 1;
grid-row-end: 2;
grid-column-start: 1;
grid-column-end: 2;
background: rgba(255, 255, 0, 0.3);
border: 0.125em solid rgba(150, 100, 0, 0.8);
color: #664400;
display: flex;
align-items: center;
justify-content: center;">
Grid Item
</div>
<div style="
grid-row-start: 2;
grid-row-end: 4;
grid-column-start: 1;
grid-column-end: 2;
background: rgba(0, 170, 255, 0.3);
color: #005;
border: 0.125em solid rgba(0, 170, 255, 0.5);
display: flex;
align-items: center;
justify-content: center;">
Grid Item
</div>
<div style="
grid-row-start: 1;
grid-row-end: 3;
grid-column-start: 2;
grid-column-end: 4;
background: rgba(250, 100, 100, 0.3);
color: #900;
border: 0.125em solid rgba(250, 100, 100, 0.5);
display: flex;
align-items: center;
justify-content: center;">
Grid Item
</div>
</div>
</div>
</section>
<section>
<h4>Grid Line</h4>
<p>Any line in the grid</p>
<div class="grid-example-wrapper grid-example-wrapper--bold-gaps">
<div class="grid-example" style="font-weight: bold;">
<div style="
align-self: center;
text-align: center;
line-height: 1.6;
margin-top: -0.25em;
">↑<br>
← Grid Lines →<br>
↓
</div>
</div>
</div>
</section>
</section>
<section>
<section>
<h3>Beginning with Grid</h3>
</section>
<section>
<h4>Basic syntax</h4>
<pre class="language-css" style="font-size: 1em"><code class="language-css">.grid-container {
display: grid;
grid-template-columns: 25% 50% 25%;
}
</code></pre>
<style>
.grid-example-wrapper--25-50-25:before {
left: 25%;
}
.grid-example-wrapper--25-50-25 .grid-example:before {
left: 75%;
}
.grid-example-wrapper--no-rows:after,
.grid-example-wrapper--no-rows .grid-example:after {
display: none;
}
</style>
<div class="grid-example-wrapper grid-example-wrapper--25-50-25 grid-example-wrapper--no-rows">
<div class="grid-example" style="
grid-template-columns: 25% 50% 25%;
grid-template-rows: auto;
height: 4em;
"></div>
</div>
</section>
<section>
<h3><a href="assets/css-training/grid-what-if-more-content.html" target="css-training">
What if there's more content than grid areas?
</a></h3>
<a href="assets/css-training/grid-what-if-more-content.html" target="css-training">Let's see in this example...</a>
<p class="small" style="margin-top: 3em;">Grid code examples stolen/modified from <a href="http://GridByExample.com">GridByExample.com</a>, from Rachel Andrew</p>
</section>
<section>
<h4>Specifically placing a grid-item:</h4>
<pre class="language-css" style="font-size: 1em"><code class="language-css">grid-column-start: 2;
grid-column-end: 3;
grid-row-start: 1;
grid-row-end: 2;</code></pre>
</section>
<section>
<h4>Specifically placing a grid-item from the end!</h4>
<pre class="language-css" style="font-size: 1em"><code class="language-css">grid-column-start: -3;
grid-column-end: -1;
grid-row-start: -2;
grid-row-end: -1;</code></pre>
<pre class="language-css" style="font-size: 1em"><code class="language-css">grid-column-start: 1;
grid-column-end: -1;</code></pre>
</section>
</section>
<!-- <section>
<section style="text-align: center">
<h3><input type="text" size="5" value="10 min." style="text-align: right" /> Break!<br>
Be back at <input type="text" size="5" value="..." style="text-align: left" />
</h3>
<p>Try to complete as many as you can on our break<br> (try at least 5):</p>
<a href="http://cssgridgarden.com/">CSSGridGarden.com</a>
</section>
</section> -->
<section>
<!-- <section>
<h3>More CSS Grid</h3>
</section> -->
<section>
<h3>Grid Item Shorthand</h3>
<pre class="language-css"><code style="font-size: 0.85em" class="language-css">.my-header {
grid-column: 1 / -1;
}
.my-content {
grid-column: 1 / span 2;
}
.my-sidebar {
grid-row: 2;
grid-column: 3;
}</code></pre>
</section>
<section style="text-align: center;">
<div class="grid-example-wrapper grid-example-wrapper--25-50-25">
<div class="grid-example" style="
grid-template-columns: 25% 50% 25%;
grid-template-rows: repeat(3, minmax(0, 1fr));
height: 14em;
">
<div style="
grid-column: 1 / -1;
padding: 0.5em;
background: rgba(250, 50, 100, 0.5);
">Header<br><small>grid-column: 1 / -1</small></div>
<div style="
grid-column: 1 / span 2;
padding: 0.5em;
background: rgba(100, 255, 0, 0.3);
">Content<br><small>grid-column: 1 / span 2</small></div>
<div style="
grid-column: 3 / span 1;
padding: 0.5em;
background: rgba(0, 50, 100, 0.3);
">
Sidebar<small><br>
grid-row: 2;<br>
grid-column: 3;</small>
</div>
</div>
</div>
</section>
</section>
<section>
<section>
<h3>Grid Units & Helpers</h3>
</section>
<section>
<h4><code>fr</code></h4>
<p>Distributes free space in a grid track</p>
<div>
<pre class="language-css"><code class="language-css">grid-template-row: 1fr 50% 1fr;</code></pre>
<pre class="language-css"><code class="language-css">1fr 1fr /* 50% 50% (Maybe) */
1fr 2fr 1fr /* 25% 50% 25% (Maybe) */
25% 1fr 1fr /* 25% 37.5% 37.5% (Maybe) */</code></pre>
</div>
</section>
<section>
<h4><a href="assets/css-training/Example 31.html" target="css-training">
<code>minmax()</code>
</a></h4>
<pre class="language-css"><code class="language-css">display: grid;
grid-gap: 10px;
grid-template-columns:
minmax(200px, 1fr) 200px 200px;
</code></pre>
<p><a href="assets/css-training/Example 31.html" target="css-training">Example</a></p>
</section>
<section>
<h4><a href="assets/css-training/grid-repeat-example.html" target="css-training">
<code>repeat(number, size)</code>
</a></h4>
<pre class="language-css"><code class="language-css">display: grid;
grid-gap: 10px;
grid-template-columns: repeat(4, 100px);
grid-template-rows: repeat(3, auto);
</code></pre>
<p><a href="assets/css-training/grid-repeat-example.html" target="css-training">Example</a></p>
</section>
<section>
<h4 style="text-align: center"><a href="assets/css-training/grid-auto-fit-vs-fill.html" target="css-training">
<code>auto-fit</code> and <code>auto-fill</code>
</a></h4>
<pre class="language-css" style="font-size: 0.7em"><code class="language-css">grid-template-columns: repeat(auto-fit, 150px)</code></pre>
<div style="margin: 0 0 1em;">Will make columns fit available space.</div>
<pre class="language-css" style="font-size: 0.7em"><code class="language-css">grid-template-columns: repeat(auto-fill, 150px)</code></pre>
<div style="margin: 0 0 1em;">Will add columns as it has room for more.</div>
<aside class="notes">
This behavior is when there aren't enough grid items to fill available area
</aside>
<p><a href="assets/css-training/grid-auto-fit-vs-fill.html" target="css-training">Example</a></p>
</section>
</section>