Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
716 lines (577 loc) · 19.3 KB
/
Copy pathindex.html
File metadata and controls
716 lines (577 loc) · 19.3 KB
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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>CSS Mastery: Grids</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<!-- Top instructions -->
<div id="topinfo"></div>
<!-- footer instructions -->
<div id="info">
<p><a href="http://standardista.com">Estelle Weyl</a> | <a href="http://twitter.com/estellevw">@estellevw</a> | <a href="http://github.com/estelle">Github</a> | Press <span class="key">→</span> to advance, <span class="key">2</span> for comments, <span class="key">4</span> to read/write notes.</p>
</div>
<div id="presentation">
<div id="presentation-counter"></div>
<div id="slides">
<div class="slide intro">
<header>
<h1>Grids</h1>
</header>
</div>
<!-- Flexbox -->
<div class="slide object">
<header><h1>Flexbox</h1></header>
<object data="files/flex.html"></object>
</div>
<!-- Flexbox -->
<div class="slide object">
<header><h1>Grid</h1></header>
<object data="files/grid.html"></object>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>Grid</h1></header>
<object data="files/grid2.html"></object>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>Grid</h1></header>
<object data="files/grid100.html"></object>
</div>
<!-- Terminology -->
<div class="slide">
<header><h1>Terminology</h1></header>
<section class="content">
<dl class="listed">
<dt>Grid lines</dt>
<dd>The vertical and horizontal lines that divide the grid and separate the columns and rows. Start counting at 1, not 0.</dd>
<dt>Grid cell</dt>
<dd>A single child or unit of a CSS grid.</dd>
<dt>Grid area</dt>
<dd>Any rectangular space surrounded by four grid lines. Can contain any number of grid cells.</dd>
<dt>Grid track</dt>
<dd>The space between two grid lines. This space can be horizontal or vertical: a grid row or grid column</dd>
<dt>Grid row</dt>
<dd>A horizontal grid track.</dd>
<dt>Grid column</dt>
<dd>A vertical grid track.</dd>
<dt>Gutter</dt>
<dd>Space between two rows and two columns.</dd>
</dl>
</section>
</div>
<!-- can i use -->
<div class="slide object">
<header><h1>Is it ready?</h1><button onclick="loadCIU('css-grid', 'cssGrid', this)">load</button></header>
<object id="cssGrid"></object>
</div>
<!-- -->
<div class="slide">
<header><h1>Properties Seen</h1></header>
<section class="content">
<p>On the parent</p>
<pre>display:
grid-template-columns:
grid-gap:</pre>
<p>On the child</p>
<pre>grid-columns:
grid-row: </pre>
<p>New values</p>
<pre>repeat()
fr</pre>
</section>
</div>
<!-- Parent Properties -->
<div class="slide intro">
<header><h1>Setting up the Grid</h1></header>
<section class="content">
</section>
</div>
<!-- -->
<div class="slide">
<header><h1>Properties declared on the parent</h1></header>
<section class="content">
<pre>display
grid-template-columns
grid-template-rows
grid-template-areas
grid-template (shorthand)
grid-column-gap
grid-row-gap
grid-gap</pre>
<pre>
justify-items
align-items
justify-content
align-content
grid-auto-columns
grid-auto-rows
grid-auto-flow
grid</pre>
</section>
</div>
<!-- -->
<div class="slide">
<header><h1>display:</h1></header>
<section class="content">
<p><code>
<strong><em>display:</em></strong> inline | block | list-item | inline-list-item | inline-block | flex | inline-flex| <strong><em>grid | inline-grid</em></strong> | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-cell | table-column-group | table-column | table-caption | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | flow | flow-root</code></p>
</section>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>Display</h1></header>
<object data="files/display2.html"></object>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>Display</h1></header>
<object data="files/display.html"></object>
</div>
<!-- -->
<div class="slide">
<header><h1>Columns and Rows</h1></header>
<section class="content">
<p>Defines the columns and rows of the grid with a space-separated list of values representing the track size</p>
<pre>grid-template-columns: none | <track-list> | <auto-track-list>
grid-template-rows: none | <track-list> | <auto-track-list></pre>
<ul>
<li><code><track-list> = <line-name>? [ <track-size> | <track-repeat> ]</code>
<li><track-size> - can be a length, a percentage, or a fraction of the free space (fr) in the grid </li>
<li><line-name> - ident or string</li>
</ul>
<pre>grid-template-columns: 200px 1fr max-content minmax(min-content, 1fr);</pre>
</section>
</div>
<!-- -->
<div class="slide">
<header><h1>grid-template-columns & rows</h1></header>
<section class="content">
<pre>grid-template-columns:
150px 150px 150px;
repeat(3, 150px);
275px repeat(2, 150px);
100px repeat(2, 1fr) 2fr;</pre>
<pre>grid-template-rows:
150px 150px 150px;
repeat(3, 150px);
275px repeat(2, 150px);
100px 1fr 2fr;</pre>
<p>Mix units!!!<br/>That's the power of grid! Or,at least one of the powers.</p>
</section>
</div>
<!-- -->
<div class="slide">
<header><h1>Naming Grid Lines</h1></header>
<section class="content">
<p>You can name grid lines:</p>
<pre>grid-template-columns:
[start] 150px 150px 150px [end];</pre>
<ul>
<li>You can name none, some or all of the lines</li>
<li>To name, put brackets around the ident</li>
</section>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>Rows & Columns: Try it out</h1></header>
<object data="files/rowcol.html"></object>
</div>
<!-- FR -->
<div class="slide">
<header><h1>fr and repeat()</h1></header>
<section class="content">
<p><strong>fr</strong><br/>
Fraction Unit<br/>describes a fraction of the <strong>available</strong> space</p>
<p><strong>repeat()</strong><br/>repeat notation: <br/><code>repeat(# of repeats, length)</code></p>
</section>
</div>
<!-- -->
<div class="slide">
<header><h1>Values</h1></header>
<section class="content">
<dl>
<dt>length or percentage</dt>
<dd>% are relative to the inline size of the grid container in column grid tracks, and the block size of the grid container in row grid tracks. If size of container depends on the size of its tracks, the % is treated as auto.</dd>
<dt>flex: fr</dt>
<dd>Positive fr value specifying the track’s flex factor. Each fr'ed track takes a share of the remaining space in proportion to its flex factor.</dd>
<dt>max-content</dt>
<dd>Equal to the largest of the max-contents in the grid track.</dd>
<dt>min-content</dt>
<dd>Equal to the largest of the min-contents in the grid track.</dd>
<dt>minmax(min, max)</dt>
<dd>A size between min and less. If max < min, then max is ignored and minmax(min,max) is treated as min.</dd>
<dt>auto</dt>
<dd>As a maximum, identical to max-content. As a minimum, represents the largest minimum size (as specified by min-width/min-height) of the grid items occupying the grid track.
</dd>
<dt>fit-content(length or percent)</dt>
<dd>Represents the formula min(max-content, max(auto, argument)), which is calculated similar to auto (i.e. minmax(auto, max-content)), except that the track size is clamped at argument if it is greater than the auto minimum.</dd>
</section>
</div>
<!-- Grid Gap -->
<div class="slide">
<header><h1>Adding gutters</h1></header>
<section class="content">
<p>Gutter size: global spacing between grid items with:</p>
<dl>
<dt>grid-column-gap</dt>
<dd>vertical space between columns</dd>
<dt>grid-row-gap</dt>
<dd>horizontal space between rows</dd>
<dt>grid-gap</dt>
<dd>Shorthand for grid-row-gap and grid-column-gap, in that order. Can take one or two lengths or percents.</dd>
</dl>
<p>Only a single size for each axis.</p>
<pre> grid-column-gap: 20px;
grid-row-gap: 1em;
grid-gap: 1em 20px;</pre>
<p>Margin works! Feature or bug?</p>
</section>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>Gutters: Try it out</h1></header>
<object data="files/gap.html"></object>
</div>
<!-- steps -->
<div class="slide">
<header><h1>Grid Steps: <a href="files/doit1.html" target="_new">Try it out ➹</a></h1></header>
<section class="content">
<ol>
<li>Create grid container with the <code>display</code> property</li>
<li>Optional: Create columns and rows with either:
<ol>
<li><code>grid-template-columns</code>, and </li>
<li><code>grid-template-rows</code></li>
</ol>
or </li>
<li>Optional: add a gutter with <code>grid gap</code> or <code>grid-column-gap</code> and
<code>grid-row-gap</code></li>
</ol>
<a href="files/doit1.html" target="_new">Try it out ➹</a>
</section>
</div>
<!-- --------------------------------------- -->
<!-- -->
<div class="slide divider">
<header><h1>Placement</h1></header>
<section class="content">
<p>Positioning Grid Items</p>
</section>
</div>
<!-- grid lines -->
<div class="slide">
<header><h1>Understanding Grid Lines</h1></header>
<section class="content gridlines">
<div><i>1</i><i>2</i><i>3</i><i>4</i></div>
<article>
<div><i>1</i><i>2</i><i>3</i><i>4</i></div>
<table>
<tr><td><div></div></td><td><div></div></td><td><div></div></td></tr>
<tr><td><div></div></td><td><div></div></td><td><div></div></td></tr>
<tr><td><div></div></td><td><div></div></td><td><div></div></td></tr>
</table></article>
</section>
</div>
<!-- -->
<div class="slide">
<header><h1>item positioning properties</h1></header>
<section class="content">
<pre>.myItem {
grid-row-start: 2;
grid-row-end: 4;
grid-column-start: 2;
grid-column-end: 5;
}</pre>
<pre>
.myItem {
grid-row: 2 / 4;
grid-column: 2 / 5;
}</pre>
<pre>.myItem {
grid-area: 2 / 2 / 4 / 5;
}</pre>
</section>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>Placing an item</h1></header>
<object data="files/placeitem.html"></object>
</div>
<!-- -->
<div class="slide">
<header><h1>The <code>grid-area</code> shorthand</h1></header>
<section class="content">
<pre>grid-area: a / b / c / d
grid-row-start / grid-column-start / grid-row-end / grid-column-end</pre>
<pre>grid-area: a / b / c;</pre>
<small>grid-column-end</code> was omitted <br>
d = named <code>grid-column-start</code> || <code>auto</code></small>
<pre>grid-area: a / b; </pre>
<small><code>grid-row-end</code> and <code>grid-column-end</code> omitted <br/>
c = named <code>grid-row-start</code> || <code>auto</code><br/>
d = named <code>grid-column-start</code> || <code>auto</code></small>
<pre>grid-area: a;</pre>
<small>Only <code>grid-row-start</code> is declared<br/>
if <code>grid-row-start</code> is named, all four longhands are set to that value. Otherwise, set to <code>auto</code></small>
</section>
</div>
<!-- -->
<div class="slide">
<header><h1>Grid Item Properties</h1></header>
<section class="content">
<pre>grid-column-start
grid-column-end
grid-column
grid-row-start
grid-row-end
grid-row
grid-area
</pre><pre>
justify-self
align-self</pre>
</section>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>Placing an item again</h1></header>
<object data="files/placeitem.html"></object>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>Holy Grail Layout</h1></header>
<object data="files/pagelayout.html"></object>
</div>
<!-- Magic layout -->
<div class="slide object">
<header><h1>Try it out! ➹</h1></header>
<object data="files/pagelayoutplay.html"></object>
<a href="files/pagelayoutplay.html" class="objectlink">Try it out ➹</a>
</div>
<!-- -->
<div class="slide">
<header><h1>Template Areas</h1></header>
<section class="content">
<p>Our magic layout:</p>
<pre>
body {
grid-template-areas:
"header header header"
"nav article aside"
"footer footer footer";
}</pre>
<pre>header {
grid-area: header;
}
nav {
grid-area: nav;
}
article {
grid-area: article;
}
aside {
grid-area: aside;
}
footer {
grid-area: footer;</pre>
</section>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>Paste the code </h1></header>
<object data="files/pagelayout2.html"></object>
</div>
<!-- --------------------------------------- -->
<!-- -->
<div class="slide intro">
<header><h1>Alignment</h1></header>
<section class="content">
</section>
</div><!-- -->
<div class="slide">
<header><h1>Alignment</h1></header>
<section class="content">
<p>Container Properties</p>
<pre>justify-items
align-items
justify-content
align-content
grid-auto-columns
grid-auto-rows
grid-auto-flow
grid</pre>
<p>Item properties</p>
<pre>justify-self
align-self</pre>
</section>
</div>
<!-- justify-items -->
<div class="slide">
<header><h1>Row alignment: <code>justify-items</code> property</h1></header>
<section class="content">
<pre><strong><em>justify-items</em></strong>:
normal | stretch | baseline | start | end | center | flex-end |
flex-start | <strong><em>legacy</em></strong> | safe | unsafe | left | right |
center | self-end | self-start | start | stretch | unset</pre>
<p>Aligns items in the inline direction (horizontal)</p>
<pre><xmp>justify-items: normal | stretch |
<baseline-position> | [ <overflow-position>? <self-position> ] |
[ legacy || [ left | right | center ] ]</xmp></pre>
<pre><baseline-position> = baseline | first baseline (start) | last baseline (end)</pre>
<pre><overflow-position>? <self-position> = [safe | unsafe]? [right | center | left |
start | flex-start | flex-end | end | self-start]</pre>
<small>aligning all the content within each cell</small>
</section>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>justify-items</h1></header>
<object data="files/parentproperties.html"></object>
</div>
<!-- -->
<div class="slide">
<header><h1>New terms</h1></header>
<section class="content">
<pre><overflow-position> = unsafe | safe</pre>
<p><code><b>safe</b></code><br/>
If it overflows the alignment container, it aligns as if the alignment mode were <code>start</code>.</p>
<p><code><b>unsafe</b></code><br/>
No matter the relative sizes overflowing, the alignment value is honored.</p>
<pre>legacy || left | center | right</pre>
<p><code><b>legacy</b></code><br/>Value inherits into descendants. Computes to <code>inherit</code> (if declared) or <code>normal</code> (if defaulting) if <code>left | center | right</code> not present. </p>
</section>
</div>
<!-- align-items -->
<div class="slide">
<header><h1>Column alignment: <code>align-items</code> property</h1></header>
<section class="content">
<p>Aligns items in the block direction (vertical)</p>
<pre><strong><em>align-items</em></strong>:
baseline | center |
end | flex-end | flex-start | left |
normal | right | safe | self-end | self-start |
start | stretch | unsafe </pre>
<ul>
<li>aligns content of all the grid cells to the content within each cell</li>
<li>individual grid cell content alignment can be overwritten with <code>align-self</code> and <code>justify-self</code>.</li></ul>
</section>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>align-items</h1></header>
<object data="files/parentproperties2.html"></object>
</div>
<!-- -->
<div class="slide">
<header><h1>Do both: <code>place-items</code> property</h1></header>
<section class="content">
<pre>place-items: <align-items> <justify-items</pre>
<ul><li>shorthand for align-items and justify items</li>
<li>Order matters! align items is first.</li>
<li>If only one value is declared, will be applied to both.</li>
</ul>
</section>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>place-items</h1></header>
<object data="files/parentproperties3.html"></object>
</div>
<!-- aligning the grid -->
<div class="slide">
<header><h1>Aligning the Grid</h1></header>
<section class="content">
<p>Defines how the items are aligned with respect to the grid if the size of all the items combined is not the same size as the container.</p>
<pre><b>justify-content</b>: baseline | center | end | flex-end | flex-start |
left | normal | right | space-around | space-between | space-evenly | start |
stretch | safe | unsafe</pre>
<pre><b>align-content</b>: baseline | center | end | flex-end | flex-start |
left | normal | right | space-between | space-evenly | start |
stretch | safe | unsafe</pre>
<p>Tip: <code>auto</code> track sizes (and only <code>auto</code> track sizes) can be stretched by the <code>align-content</code> and <code>justify-content</code> properties</p>
</section>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>justify & align content</h1></header>
<object data="files/content.html"></object>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1><code>justify-content</code></h1></header>
<object data="files/content2.html"></object>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1><code>align-content</code></h1></header>
<object data="files/content3.html"></object>
</div>
<!-- implicit track sizing -->
<div class="slide">
<header><h1>Implicit track sizing </h1></header>
<section class="content">
<p>When items are placed outside of the tracks defined by <code>grid-template-rows</code>, <code>grid-template-columns</code>, and <code>grid-template-areas</code>, implicit grid tracks by added. These properties size those tracks</p>
<pre>grid-auto-columns:
grid-auto-rows:
grid-auto-flow:</pre>
</section>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>automatic flow</h1></header>
<object data="files/extracols.html"></object>
</div>
<!-- grid example -->
<div class="slide object">
<header><h1>White Space</h1></header>
<object data="files/extracols2.html"></object>
</div>
<!--NEXT-->
<div class="slide">
<header><h1>Background & Borders</h1></header>
<section class="content">
<h1><a href="../borders/">Next ➹</a></h1></section>
</div>
<div class="slide dots">
<header><h1>Table of Content</h1></header>
<section>
<ol class="column2">
<li><a href="../intro">Introduction</a></li>
<li><a href="../selectors">Selectors</a></li>
<li><a href="../selectors">Specificity</a></li>
<li><a href="../generated">Generated Content</a></li>
<li><a href="../media">Media Queries</a></li>
<li><a href="../sass">Best Practices</a></li>
<li><a href="../debugging">Debugging</a></li>
<li><a href="../colors">Colors & Transparency </a></li>
<li><a href="../flexbox">Flexbox</a></li>
<li><a href="../tables">Tables</a></li>
<li><a href="../grid">Grids</a></li>
<li><a href="../borders">Backgrounds & Borders </a></li>
<li><a href="../gradients">Gradients</a></li>
<li><a href="../transforms">Transforms</a></li>
<li><a href="../animations">Transitions & Animation</a></li>
<li><a href="../other">Other Features</a></li>
</ol>
</section>
</div>
<!-- TOC -->
<div class="slide">
<header><h1>Links</h1></header>
<section class="content">
<ul>
</ul>
</section>
</div>
</div>
<header>
<nav>
<button class="cancel" id="back">Back</button><button class="done" id="next">Next</button>
</nav>
</header>
</div>
<script src="slides.js"></script>
</body>
</html>