-
Notifications
You must be signed in to change notification settings - Fork 709
/
Copy pathoverview.html
executable file
·1083 lines (814 loc) · 35.8 KB
/
overview.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 PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang=en xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:v="urn:schemas-microsoft-com:vml">
<head><meta content="text/html;charset=utf-8" http-equiv=Content-Type>
<title>CSS Grid Positioning Module Level 3</title>
<link href="../default.css" rel=stylesheet type="text/css">
<style type="text/css">
.cols { width: 500px; height: 200px; background: #fff; position: relative; border: solid 10px blue; margin: 0.5em 2em 1em 0; font: bold 14px/19px Arial, sans-serif }
.cols p { padding: 3px; margin: 0; }
.gap { position: absolute; background: black; width: 5px; bottom: 0px; top: 0px; border: 10px solid red; border-top-width: 0; border-bottom-width: 0; }
.rep { position: absolute; background: #333; height: 110px; width: 100px; color: white; z-index: 4 }
.issue { color:red; font-style:italic;}
.todo { background:yellow; font-style:italic;}
</style>
<link href="http://www.w3.org/StyleSheets/TR/W3C-MO.css" rel=stylesheet
type="text/css">
<body>
<div class=head> <!--begin-logo-->
<p><a class=logo href="http://www.w3.org/" rel=home><img alt=W3C height=48
src="http://www.w3.org/Icons/w3c_home" width=72></a><a class=logo
href="../../" rel=in-activity><img alt="CSS WG"
src="../../../Woolly/woolly-icon.png"></a> <span
class=id>MO-css3-grid-20111026</span></p>
<!--end-logo-->
<h1>CSS Grid Positioning Module Level 3</h1>
<h2 class="no-num no-toc" id=longstatus-date>W3C Member-only Draft 26
October 2011</h2>
<dl>
<dt>This version:
<dd><a
href="http://www.w3.org/TR/2011/MO-css3-grid-20111026/">http://www.w3.org/TR/2011/MO-css3-grid-20111026</a>
<dt>Latest version:
<dd><a
href="http://www.w3.org/TR/css3-grid">http://www.w3.org/TR/css3-grid</a>
<dt>Previous version:
<dd>none
<dt>Feedback:</dt>
<dd><a href="mailto:www-style@w3.org?subject=%5B[css-grid-position]%5D%20feedback"
>www-style@w3.org</a>
with subject line “<kbd>[css-grid-position]
<var>… message topic …</var></kbd>”
(<a rel="discussion" href="http://lists.w3.org/Archives/Public/www-style/"
>archives</a>)
<dt>Editors:
<dd>Alex Mogilevsky, Microsoft, <a
href="mailto:alexmog@microsoft.com">alexmog@microsoft.com</a>
<dt>Authors:
<dd>Alex Mogilevsky, Microsoft, <a
href="mailto:alexmog@microsoft.com">alexmog@microsoft.com</a>
<dd>Markus Mielke, Microsoft, <a
href="mailto:alexmog@microsoft.com">mmielke@microsoft.com</a>
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> © 2011 <a
href="http://www.w3.org/"><acronym
title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a
href="http://www.csail.mit.edu/"><acronym
title="Massachusetts Institute of Technology">MIT</acronym></a>, <a
href="http://www.ercim.eu/"><acronym
title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a
href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a
href="http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
<!--end-copyright-->
<hr title="Separator for header">
</div>
<p
style="background: #fdd; color: red; font-weight: bold; text-align: center; padding: .5em; border: thick solid red; border-radius: 1em; position: fixed; bottom: 1em; left: 1em; right: 1em;">This
specification is not being actively maintained, and should not be used as
a guide for implementations. It may be revived in the future, but for now
should be considered obsolete. <br>
If you have questions or comments on this specification, please send an
email to the CSS Working Group's mailing list at <a
href="mailto:www-style@w3.org">www-style@w3.org</a>. (Before sending mail
for the first time, you have to subscribe at <a
href="http://lists.w3.org/Archives/Public/www-style/">http://lists.w3.org/Archives/Public/www-style/</a>.)
<h2 class="no-num no-toc" id=abstract>Abstract</h2>
<p>This module describes integration of grid-based layout (similar to the
grids traditionally used in books and newspapers) with CSS sizing and
positioning.
<h2 class="no-num no-toc" id=status>Status of this document</h2>
<!--begin-status-->
<p>This is a member-only draft. It may be updated, replaced or obsoleted by
other documents at any time. It is inappropriate to cite this document as
other than work in progress.
<p>The (<a
href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
mailing list <a
href="mailto:www-style@w3.org?Subject=%5Bcss3-grid%5D%20PUT%20SUBJECT%20HERE">
w3c-css-wg@w3.org</a> is preferred for discussion of this specification.
<p>This document was produced for the <a href="/Style/CSS/members">CSS
Working Group</a> (part of the <a href="/Style/">Style Activity</a>).
<!--end-status-->
<p>This is the first public working draft of this module.
<h2 class="no-num no-toc" id=contents>Table of contents</h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#dependencies"><span class=secno>1. </span>Dependencies on
other modules</a>
<li><a href="#introduction"><span class=secno>2. </span>Introduction</a>
<li><a href="#examples"><span class=secno>3. </span>Examples</a>
<ul class=toc>
<li><a href="#example-1"><span class=secno>3.1. </span>Example 1</a>
<li><a href="#example-2-"><span class=secno>3.2. </span>Example 2 </a>
</ul>
<li><a href="#grid-declarations"><span class=secno>4. </span>Grid
declarations</a>
<ul class=toc>
<li><a href="#explicit-grid"><span class=secno>4.1. </span>Explicit
grid</a>
<ul class=toc>
<li><a href="#grid-columns-and-grid-rows-properties"><span
class=secno>4.1.1. </span>‘<code
class=property>grid-columns</code>’ and ‘<code
class=property>grid-rows</code>’ properties</a>
</ul>
<li><a href="#implicit-grid"><span class=secno>4.2. </span>Implicit
grid</a>
<ul class=toc>
<li><a href="#multi-column-element"><span class=secno>4.2.1.
</span>Multi-column element</a>
<li><a href="#table"><span class=secno>4.2.2. </span>Table</a>
<li><a href="#viewport"><span class=secno>4.2.3. </span>Viewport</a>
<li><a href="#priority-of-explicit-grid-definition"><span
class=secno>4.2.4. </span>Priority of explicit grid definition</a>
</ul>
</ul>
<li><a href="#grid-units"><span class=secno>5. </span>Grid units</a>
<ul class=toc>
<li><a href="#applicability-of-grid-units"><span class=secno>5.1.
</span>Applicability of grid units</a>
<li><a href="#grid-container"><span class=secno>5.2. </span>Grid
container</a>
<li><a href="#reference-point-for-grid-units"><span class=secno>5.3.
</span>Reference point for grid units</a>
</ul>
<li><a href="#grid-in-overflow"><span class=secno>6. </span>Grid in
overflow</a>
<li><a href="#issues"><span class=secno>7. </span>Issues</a>
<ul class=toc>
<li><a href="#grid-on-shrink-to-fit-elements"><span class=secno>7.1.
</span>Grid on shrink-to-fit elements</a>
<li><a href="#additional-implicit-grid-lines"><span class=secno>7.2.
</span>Additional implicit grid lines</a>
<li><a href="#snap-to-grid"><span class=secno>7.3. </span>Snap to
grid</a>
<li><a href="#undefined-grid-and-notion-of-39default39"><span
class=secno>7.4. </span>Undefined grid and notion of 'default'
grid</a>
<li><a href="#page-grid"><span class=secno>7.5. </span>Page grid</a>
<li><a href="#named-grid-lines-and-cells"><span class=secno>7.6.
</span>Named grid lines and cells</a>
<li><a href="#templates-in-css3-advanced-layout-module"><span
class=secno>7.7. </span>Templates in CSS3 Advanced Layout module</a>
</ul>
<li class=no-num><a href="#acknowledgments">Acknowledgments</a>
<li class=no-num><a href="#references">References</a>
<ul class=toc>
<li class=no-num><a href="#normative-references">Normative
references</a>
<li class=no-num><a href="#other-references">Other references</a>
</ul>
<li class=no-num><a href="#index">Index</a>
<li class=no-num><a href="#property-index">Property index</a>
</ul>
<!--end-toc-->
<h2 id=dependencies><span class=secno>1. </span>Dependencies on other
modules</h2>
<p>This CSS3 module depends on the following other CSS3 modules:
<ul>
<li><a href="#CSS3VAL" rel=biblioentry>[CSS3VAL]<!--{{!CSS3VAL}}--></a>
</ul>
<p>It has non-normative (informative) references to the following other
CSS3 modules:
<ul>
<li><a href="#CSS3COL" rel=biblioentry>[CSS3COL]<!--{{CSS3COL}}--></a>
<li><a href="#CSS3GCPM" rel=biblioentry>[CSS3GCPM]<!--{{CSS3GCPM}}--></a>
<li><a href="#MEDIAQ" rel=biblioentry>[MEDIAQ]<!--{{MEDIAQ}}--></a>
<li><a href="#CSS3LAYOUT"
rel=biblioentry>[CSS3LAYOUT]<!--{{CSS3LAYOUT}}--></a>
</ul>
<h2 id=introduction><span class=secno>2. </span>Introduction</h2>
<p>Grid systems have provided great value to print designers for many years
<a href="#THEGRID" rel=biblioentry>[THEGRID]<!--{{THEGRID}}--></a>. Now
same concepts are applied to online content <a href="#SXSWGRIDS"
rel=biblioentry>[SXSWGRIDS]<!--{{SXSWGRIDS}}--></a>, <a href="#AGBDL"
rel=biblioentry>[AGBDL]<!--{{AGBDL}}--></a>. Unlike print media however,
dimensions of online devices vary broadly; a single fixed-sized grid that
worked perfectly for print pages only works in a subset of web scenarios.
Really adaptable solutions require dealing with a grid that adapts to fit
devices of varying form factors.
<p>This module adds capabilities for sizing and positioning in terms of a
scalable grid . The grid can be specified directly by author, or can be
implied from existing two-dimensional structures (tables or multi-column
elements).
<p>Grid positioning addresses layout in continuous media and in paged
media.
<h2 id=examples><span class=secno>3. </span>Examples</h2>
<p>Let's start with an illustration of grid in action.
<h3 id=example-1><span class=secno>3.1. </span>Example 1</h3>
<div class=figure> <img
alt="example of a 3-column layout with an image that spans the whole page and a 2-column box in bottom left corner"
src="grid1_small.jpg">
<p class=caption>Floats in multi-column layout</p>
</div>
<p style="height: 18px">Figure 1 shows a 3-column layout in paged media. It
can be seen as a grid with 6 vertical lines (at each column boundary) and
horizontal lines at margins.
<div class=example>
<pre>body { columns:3; column-gap:2em; }
float1 { float:page bottom left; <strong>width:3gr;</strong> }
/* Figure 1 */
</pre>
</div>
<p>The statement "float:page bottom left" positions the image at
the bottom left corner of the page (as defined in <a href="#CSS3GCPM"
rel=biblioentry>[CSS3GCPM]<!--{{CSS3GCPM}}--></a>)
<p>Property "width:3gr" makes it 3 "grid units" wide,
where a "grid unit" is the distance between two adjacent grid
lines. Each boundary between a column and a gap automatically produces a
grid line, therefore to specify "two columns, including the gap
between columns, but not including any gaps outside the columns" we
can just say "3gr".
<p>Also, in this example the author has added a horizontal line to align
illustrations with. This can be done by explicitly defining grid lines:
<div class=example>
<pre>
body { columns:3; column-gap:2em;
<strong>grid-rows: 1.5in 1fr;</strong> }
div.illustrations
{ float:page top left; width:5gr; height:1gr;}
float1 { float:page bottom left; width:3gr; }
/* Figure 2 */
</pre>
</div>
<p>In this example, "grid-rows" divides vertical space with
explicit grid lines.
<p>"1fr" is a flex unit ('fr' for 'fraction'). If
multiple flex units are used, they take space proportional to their
values. If we wanted to define vertical lines that would exactly match the
3-column layout with 2em gaps we could say
<div class=example>
<pre>
grid-columns: 1fr 2em 1fr 2em 1fr;
</pre>
</div>
<p>When only one value has a 'fr' unit (as in "grid-rows:
1.5in 1fr" above), it just takes all remaining space regardless of
the number.
<h3 id=example-2-><span class=secno>3.2. </span>Example 2</h3>
<p>The following example illustrates the use of a grid in construction of a
complex web site (see <a href="#SXSWGRIDS"
rel=biblioentry>[SXSWGRIDS]<!--{{SXSWGRIDS}}--></a> for how exactly this
was built). Note how groups of elements are aligned with different sets of
grid lines.
<div class=figure> <img alt="[image of a complex page with overlaid grid]"
src="Yeeaahh_grid.png" style="float:left; width:9cm;"> <img
alt="[image of complex page]" src=Yeeaahh.png
style="float:left; width:9cm;">
<p class=caption style="clear:left">Complex site designed with a grid</p>
</div>
<h2 id=grid-declarations><span class=secno>4. </span>Grid declarations</h2>
<p>There are two ways to define a grid.
<ol>
<li>Explicit grid: defined with 'grid-columns',
'grid-rows' properties.
<li>Implicit grid: automatically created by elements with a natural grid
structure (multi-column elements and tables).
</ol>
<h3 id=explicit-grid><span class=secno>4.1. </span>Explicit grid</h3>
<p>Grid lines can be defined in terms of rows and columns. Rows are
always horizontal and columns are always vertical (this doesn't change
in vertical writing modes)
<h4 id=grid-columns-and-grid-rows-properties><span class=secno>4.1.1.
</span>‘<a href="#grid-columns"><code
class=property>grid-columns</code></a>’ and ‘<a
href="#grid-rows"><code class=property>grid-rows</code></a>’
properties</h4>
<table class=propdef>
<tbody>
<tr>
<td>Name:
<td> <dfn id=grid-columns>grid-columns</dfn>
<tr>
<td>Value:
<td>[[<length>|<percentage>|<fraction>] | <br>
repeat([<length>|<percentage>|<fraction> ]+)]+ | <br>
none | inherit
<tr>
<td>Initial:
<td>none
<tr>
<td>Applies to:
<td>non-replaced block-level elements
<tr>
<td>Inherited:
<td>no
<tr>
<td>Percentages:
<td><span>refer to width of the block</span>
<tr>
<td>Media:
<td>visual, paged
<tr>
<td>Computed value:
<td>specified value
</table>
<table class=propdef>
<tbody>
<tr>
<td>Name:
<td> <dfn id=grid-rows>grid-rows</dfn>
<tr>
<td>Value:
<td>[[<length>|<percentage>|<fraction>] | <br>
([<length>|<percentage>|<fraction> ]+)[‘<code
class=css>[</code>’<integer>‘<code
class=css>]</code>’]? ]+ | <br>
none | inherit
<tr>
<td>Initial:
<td>none
<tr>
<td>Applies to:
<td>non-replaced block-level elements
<tr>
<td>Inherited:
<td>no
<tr>
<td>Percentages:
<td><span>refer to height of block</span>
<tr>
<td>Media:
<td>visual, paged
<tr>
<td>Computed value:
<td>specified value
</table>
<p>When grid-rows or grid-columns are specified, grid lines are defined as
follows:
<ol>
<li>'start' edge of content box (logical start according to
writing mode) defines a grid line
<li>each row or column of specified grid adds one line at the specified
distance from previous line
<li>if the last specified row or column does not reach the 'end'
edge of the content box, another grid line is added at the edge of the
content box
</ol>
<p>
<p>Space for each column or row of the grid can be defined as
<ul>
<li><b>Length</b>.
<ul>
<li>Note that gr unit can also be used here (it refers to grid of the
containing block)
</ul>
<li><b>Percentage</b> of containing block height and width
<ul>
<li>Exact behavior of percentage when mixed with other units and/or
total percentage not equal to 100% is UA-specific. If possible UA
should apply the same distribution algorithm as for column widths of an
empty table
</ul>
<li><strong>Fraction</strong> is a non-negative floating-point number
followed by 'fr'. Each fraction value takes portion of available
space proportional to the number.
</ul>
<p>For example this rule
<div class=example>
<pre>div { grid-columns: 50% 1fr 1fr 4em }
</pre>
</div>
<ul>
<li>adds one grid line in the middle of containing block,
<li>another one 4em from the right
<li>another one in the middle of remaining space
</ul>
<p class=issue>'fr' needs a precise definition. It is possible that
there isn't any space to distribute between fractions, what happens
then? fr becomes zero?
<p>Grid lines can be defined in repeating groups using "repeat()"
construct. Nested repeating groups are not allowed.
<p>For example this rule
<div class=example>
<pre>div { grid-rows: 4em repeat(0.25em 1em); }
</pre>
</div>
<ul>
<li>defines a header row of 4em
<li>adds as many additional rows as necessary, alternating heights of
0.25em and 1em.
</ul>
<p class=issue>It was proposed that property names refer to
horizontalvertical lines instead of rows/columns (because they in fact
define lines, not rows and columns). Possible alternatives: <strong>
grid-horizontal-lines/grid-vertical-lines; </strong>or perhaps simply
<strong> grid-horizontal/grid-vertical.</strong>
<p class=issue>It was proposed to have syntax for repeating a certain
number of times. It is not strictly necessary (if the number of times is
known the values can be repeated inline) but handy.
<h3 id=implicit-grid><span class=secno>4.2. </span>Implicit grid</h3>
<p>Elements with a natural grid structure automatically define a grid that
aligns with the structure. It is called an<em> implicit grid</em>.<em>
</em>Such elements are
<h4 id=multi-column-element><span class=secno>4.2.1. </span>Multi-column
element</h4>
<p>Left and right edges of each column form a grid line. There are twice as
many grid lines as there are columns.
<h4 id=table><span class=secno>4.2.2. </span>Table</h4>
<p>Border box of each table column defines two vertical lines; border box
of each table row defines two horizontal lines. In collapsing border model
there is always a pair of identical grid lines between each pair of rows
and columns. Maintaining same amount of lines per column keeps the
definition consistent across all table models and multi-column elements
(e.g. a span over 2 columns is always 3gr)
<p class=issue>Definition of a grid for a table is only meaningful if there
is something that can use it. Currently there are no table floats. Should
there be? Something like "float:top left table; float-offset:2gr
4gr" would use the table grid. Is there a use case for such floats?
There is still absolute positioning that can target at table of course...
<h4 id=viewport><span class=secno>4.2.3. </span>Viewport</h4>
<p>Viewport always defines a single-cell grid with the size of the
viewport.
<h4 id=priority-of-explicit-grid-definition><span class=secno>4.2.4.
</span>Priority of explicit grid definition</h4>
<p>If explicit grid properties grid-columns or grid-rows are specified on
an element with an implicit grid, the explicit properties have priority.
<h2 id=grid-units><span class=secno>5. </span>Grid units</h2>
<p><b>‘<code class=property>gr</code>’</b> is used to position
in relation to the grid lines. Actual value of each gr depends on the grid
cell in which it is used.
<p>Example
<div class=example>
<pre>div { columns:3; }
div img { float: top left column;
float-offset: 2gr;
width: 1gr }
</pre>
</div>
<p>The image is positioned over the 2<sup>nd</sup> column (left edge of
second column is 2<sup>nd</sup> grid line from left; its width is the
distance to the next grid line).
<div class=cols>
<p>Lorem ipsum dolor<br>
sit amet. Nam at jus.<br>
Sed imp er di et ris.<br>
Cur abi tur et sapen.<br>
Vivamus a metus.<br>
Aenean at risus<br>
pharetra ante luctu<br>
feugiat quis enim.<br>
Cum sociis natoque<br>
penatibus et magni.
<div style="position: absolute; left: 175px; top: 115px; z-index: 6">
<p>Lorem ipsum dolor<br>
sit amet. Nam at jus.<br>
Sed imp er di et ris.<br>
Cur abi tur et sapen.
</div>
<div style="position: absolute; left: 350px; top: 0px; z-index: 6">
<p>Lorem ipsum dolor<br>
sit amet. Nam at jus.<br>
Sed imp er di et ris.<br>
Cur abi tur et sapen.<br>
Vivamus a metus.<br>
Aenean at risus<br>
pharetra ante luctu<br>
feugiat quis enim.<br>
Cum sociis natoque<br>
penatibus et magni.
</div>
<div class=rep style="top: 0; left: 175px; width: 150px"></div>
<div class=gap style="left: 150px"></div>
<div class=gap style="left: 325px"></div>
</div>
<p>Fractions of gr unit can be used too. In this example
<div class=example>
<pre>div img { float:left column; float-offset: 0.5gr; width: 2gr; }
</pre>
</div>
<p>the image takes exactly the width required to stretch from the middle of
first column to the middle of second column. width:2gr in the example
doesn't start from exactly a grid line, therefore it is calculated as
a sum of grid parts (2gr = 0.5gr + 1gr + 0.5gr), which ends in the middle
of second column.
<div class=cols>
<p style="width:140px;">Lorem ipsum dolor sit amet. Nam at jus. <span
style="float:right; width: 68px; height:110px; "></span> Sed imp er di et
ris. Cur abi tur et sapen. Fusce sed ligula a turpis. Vivamus a metus.</p>
<div
style="position: absolute; left: 175px; width:140px; top: 0; z-index:4;">
<p style="width:140px"> Lorem ipsum dolor sit amet. Nam jus. <br>
<span style="float:left; width: 78px; height:110px; "></span> <span
class=rep style="left: -100px; top:auto; width: 175px"></span> Sed imp
er di et ris. Cur abi tur et sapen. Fusce sed ligula a turpis. </p>
</div>
<div style="position: absolute; left: 350px; top: 0; z-index: 6;">
<p style="width:140px;">Lorem ipsum dolor<br>
sit amet. Nam at jus.<br>
Sed imp er di et ris.<br>
Cur abi tur et sapen.<br>
Aenean at risus<br>
pharetra ante luctu<br>
feugiat quis enim.<br>
Cum sociis natoque<br>
penatibus et magni.
</div>
<div class=gap style="left: 150px"></div>
<div class=gap style="left: 325px"></div>
</div>
<h3 id=applicability-of-grid-units><span class=secno>5.1.
</span>Applicability of grid units</h3>
<p>Grid units are applicable to all properties of block elements that take
values of type <a
href="http://www.w3.org/TR/css3-values/#lengths"><length></a>.
<p>When applied to margins, borders and padding, grid units refer to grid
lines in the direction of line progression (horizontal in layout with
horizontal lines).
<p>Grid units never apply to inline elements, including inline blocks.
<h3 id=grid-container><span class=secno>5.2. </span>Grid container</h3>
<p>Since separate grids can be defined on nested elements, it must be
defined which grid is referred to for every use of 'gr' unit.
<p>For all cases where 'gr' unit is applicable the grid is taken
from the containing block (which is found as defined as defined in CSS2.1
section 10.1).
<p>In this example, div1 is the positioning parent and therefore grid of
div1 is used for positioning:
<div class=example>
<pre><style>
<strong>.div1 { position:absolute; grid-columns:4em repeat(1em 4em); }</strong> /* this grid is used */
.div2 { columns-width:10em; column-gap:1em; }
img { position:absolute; left:2gr; width:3gr; }
</style>
<div class="div1">
<div class="div2">
<img />
</div>
</div>
</pre>
</div>
<p>However in the next example, grid of div2 is used by the float, because
it is the float's containing block:
<div class=example>
<pre><style>
.div1 { position:absolute; grid-columns:4.5em (1em 4.5em); }
<strong>.div2 { columns-width:10em; column-gap:1em; }</strong> /* this grid is used */
img { float:left; float-offset:2gr; width:3gr; }
</style>
<div class="div1">
<div class="div2">
<img />
</div>
</div>
</pre>
</div>
<h3 id=reference-point-for-grid-units><span class=secno>5.3.
</span>Reference point for grid units</h3>
<p class=issue>Calculating grid units require a reference point within the
grid and direction. This needs a precise definition. For the same element,
grid units for position and size may have different reference points (but
probably not different directions).
<p class=issue>Define how 'gr' is used on in-flow blocks. Is
'1gr' generally equivalent to '100%' there?
<h2 id=grid-in-overflow><span class=secno>6. </span>Grid in overflow</h2>
<p>When a measure defined in grid units extends outside the boundaries of
grid container, grid lines are repeated according to the following rules
<ul>
<li>If overflow is in positive direction (right/bottom in
left-to-right/top-to-bottom flow, direction of text and block progression
in other flows)
<ul>
<li>Explicit grid
<ul>
<li>If the grid definition ends with a repeat pattern (regardless of
repeat count), the same pattern continues indefinitely
<li>Otherwise, the last column or row size is repeated
</ul>
<li>Multi-column element
<ul>
<li>Additional (gap, column) pairs are added.
<ul>
<li>Current definition of multi-column layout doesn't allow
variable-width columns; when it does, the last column with the last
column gap should be repeated
</ul>
</ul>
<li>Table
<ul>
<li>The last column is repeated
</ul>
<li>Viewport
<ul>
<li>Additional lines are added, separated by the size of the viewport
</ul>
</ul>
<li>If overflow is in negative direction
<ul>
<li>The same sequence is used as in positive direction, but mirrored.
</ul>
</ul>
<p class=issue>Add an example
<p class=issue>How important is an overflow grid? What use cases would
suffer if 'gr' is just set to zero in overflow?
<h2 id=issues><span class=secno>7. </span>Issues</h2>
<h3 id=grid-on-shrink-to-fit-elements><span class=secno>7.1. </span>Grid on
shrink-to-fit elements</h3>
<p class=issue>Specifying a grid on an element with shrink-to-fit sizing
can create difficult or unsolvable problems, similar to use percentages
within shrink to fit but even more complicated. Consider ignoring grid
definition on anything shrink-to-fit.
<h3 id=additional-implicit-grid-lines><span class=secno>7.2.
</span>Additional implicit grid lines</h3>
<p class=issue>On the implicit grids for multi-column elements, it might be
useful to have one grid line on the left and right edge of each column, as
well as a single grid line between each pair of columns. Perhaps doing the
same thing for tables, one line on each side of the border spacing and
another at the row/column boundary.
<h3 id=snap-to-grid><span class=secno>7.3. </span>Snap to grid</h3>
<p class=issue>Should there be an option to align flow content to next
available gridline? It opens really cool scenarios. But are they
compelling enough to create a next available notion?
<h3 id=undefined-grid-and-notion-of-39default39><span class=secno>7.4.
</span>Undefined grid and notion of 'default' grid</h3>
<p class=issue>When a grid unit is used in context where there isn't an
explicit or implicit grid specified, what should it be? Reaching to
nearest parent with a defined grid may or may not be the right choice.
There is an option to give any element a "default grid" of one
cell.
<h3 id=page-grid><span class=secno>7.5. </span>Page grid</h3>
<p>It must be possible to define different grids for left and right pages.
Also, any page with different dimensions (such as named pages) should be
able to define its own grid.
<p class=issue>Add grid-columns/grid-rows to @page rule
<h3 id=named-grid-lines-and-cells><span class=secno>7.6. </span>Named grid
lines and cells</h3>
<p class=issue>If grid is used extensively, named grid locations would be
quite helpful. Defining named grid lines could look for example like this:
<div class=example>
<pre>body { grid-columns: "left-edge" 1fr 1em 1fr 0.5em "center" 0.5em 1fr 1em 1fr "right-edge";
</pre>
</div>
<p class=issue>This syntax doesn't easily extend to named cells. It was
noted however that named cells also open a possibility for named flows (by
providing a sequence of named cells to fill) which makes the feature quite
attractive and further approaches Advanced Layout scenarios.
<h3 id=templates-in-css3-advanced-layout-module><span class=secno>7.7.
</span>Templates in CSS3 Advanced Layout module</h3>
<p class=issue>"Template-based positioning" in CSS3 Advanced Layout module
<a href="#CSS3LAYOUT"
rel=biblioentry>[CSS3LAYOUT]<!--{{CSS3LAYOUT}}--></a> defines scalable
templates for content to fill and also used the term "grid".
<p><span class=issue>The relationship between these modules certainly needs
to be well defined. </span>
<p><span class=issue>Note that technically these modules are not
contradictory (as long as is defined how an advanced-layout template
produces an implicit grid).</span>
<h2 class=no-num id=acknowledgments>Acknowledgments</h2>
<p class=MsoNormal>This specification is made possible by input from Håkon
Wium Lie, Steve Zilles, Mike Duggan, Bill Hill, Geraldine Wade, Rikkert
Koppes, Peter Linss [to be added].
<p>Thanks to Khoi Vinh for the “Yeeaahh!” Example.
<p>
<h2 class=no-num id=references>References</h2>
<h3 class=no-num id=normative-references>Normative references</h3>
<!--begin-normative-->
<!-- Sorted by label -->
<dl class=bibliography>
<dt style="display: none"><!-- keeps the doc valid if the DL is empty -->
<!---->
<dt id=CSS3VAL>[CSS3VAL]
<dd>Håkon Wium Lie; Tab Atkins; Elika J. Etemad. <a
href="http://www.w3.org/TR/2011/WD-css3-values-20110906/"><cite>CSS
Values and Units Module Level 3.</cite></a> 6 September 2011. W3C Working
Draft. (Work in progress.) URL: <a
href="http://www.w3.org/TR/2011/WD-css3-values-20110906/">http://www.w3.org/TR/2011/WD-css3-values-20110906/</a>
</dd>
<!---->
</dl>
<!--end-normative-->
<h3 class=no-num id=other-references>Other references</h3>
<!--begin-informative-->
<!-- Sorted by label -->
<dl class=bibliography>
<dt style="display: none"><!-- keeps the doc valid if the DL is empty -->
<!---->
<dt id=AGBDL>[AGBDL]
<dd>Charles Jacobs; et al. <a
href="http://grail.cs.washington.edu/pub/papers/Jacobs2003.pdf">“Adaptive
Grid Based Document Layout”</a> in: <cite>ACM Transactions on
Graphics.</cite> 22. 3. pp. 838–847. July 2003. URL: <a
href="http://grail.cs.washington.edu/pub/papers/Jacobs2003.pdf">http://grail.cs.washington.edu/pub/papers/Jacobs2003.pdf</a>
</dd>
<!---->
<dt id=CSS3COL>[CSS3COL]
<dd>Håkon Wium Lie. <a
href="http://www.w3.org/TR/2011/CR-css3-multicol-20110412"><cite>CSS
Multi-column Layout Module.</cite></a> 12 April 2011. W3C Candidate
Recommendation. (Work in progress.) URL: <a
href="http://www.w3.org/TR/2011/CR-css3-multicol-20110412">http://www.w3.org/TR/2011/CR-css3-multicol-20110412</a>
</dd>
<!---->
<dt id=CSS3GCPM>[CSS3GCPM]
<dd>Håkon Wium Lie. <a
href="http://www.w3.org/TR/2010/WD-css3-gcpm-20100608"><cite>CSS
Generated Content for Paged Media Module.</cite></a> 8 June 2010. W3C
Working Draft. (Work in progress.) URL: <a
href="http://www.w3.org/TR/2010/WD-css3-gcpm-20100608">http://www.w3.org/TR/2010/WD-css3-gcpm-20100608</a>
</dd>
<!---->
<dt id=CSS3LAYOUT>[CSS3LAYOUT]
<dd>Bert Bos; César Acebal. <a
href="http://www.w3.org/TR/2010/WD-css3-layout-20100429"><cite>CSS
Template Layout Module.</cite></a> 29 April 2010. W3C Working Draft.
(Work in progress.) URL: <a
href="http://www.w3.org/TR/2010/WD-css3-layout-20100429">http://www.w3.org/TR/2010/WD-css3-layout-20100429</a>
</dd>
<!---->
<dt id=MEDIAQ>[MEDIAQ]
<dd>Håkon Wium Lie; et al. <a
href="http://www.w3.org/TR/2010/CR-css3-mediaqueries-20100727/"><cite>Media
Queries.</cite></a> 27 July 2010. W3C Candidate Recommendation. (Work in
progress.) URL: <a
href="http://www.w3.org/TR/2010/CR-css3-mediaqueries-20100727/">http://www.w3.org/TR/2010/CR-css3-mediaqueries-20100727/</a>
</dd>
<!---->
<dt id=SXSWGRIDS>[SXSWGRIDS]
<dd>Khoi Vinh; Mark Boulton. <a
href="http://www.subtraction.com/pics/0703/grids_are_good.pdf"><cite>Grids
Are Good.</cite></a> March 2007. SXSW Interactive, Austin, TX. URL: <a
href="http://www.subtraction.com/pics/0703/grids_are_good.pdf">http://www.subtraction.com/pics/0703/grids_are_good.pdf</a>
</dd>
<!---->
<dt id=THEGRID>[THEGRID]
<dd>Allen Hurlburt. <cite>Grid: A Modular System for the Design and
Production of Newpapers, Magazines, and Books.</cite> Wiley. 1982. ISBN
0-471-28923-X.</dd>
<!---->
</dl>
<!--end-informative-->
<h2 class=no-num id=index>Index</h2>
<!--begin-index-->
<ul class=indexlist>
<li>grid-columns, <a href="#grid-columns"
title=grid-columns><strong>4.1.1.</strong></a>