-
Notifications
You must be signed in to change notification settings - Fork 707
/
Copy pathOverview.bs
1402 lines (1093 loc) · 69.6 KB
/
Overview.bs
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
<pre class='metadata'>
Title: CSS Transforms Module Level 1
Status: ED
Work Status: Refining
ED: https://drafts.csswg.org/css-transforms/
TR: https://www.w3.org/TR/css-transforms-1/
Previous Version: https://www.w3.org/TR/2012/WD-css3-transforms-20120911/
Previous Version: https://www.w3.org/TR/2012/WD-css3-transforms-20120403/
Shortname: css-transforms
Link Defaults: svg (property) to/stroke/fill, css-masking-1 (property) clip/clip-path, filters-1 (property) filter, css-backgrounds-3 (value) fixed, html (element) a
Level: 1
Group: fxtf
Editor: Simon Fraser, Apple Inc http://www.apple.com/, simon.fraser@apple.com, w3cid 44066
Editor: Dean Jackson, Apple Inc http://www.apple.com/, dino@apple.com, w3cid 42080
Editor: Theresa O'Connor, Apple Inc http://www.apple.com/, eoconnor@apple.com
Editor: Dirk Schulze, Adobe Systems Inc http://www.adobe.com/, dschulze@adobe.com, w3cid 51803
Former Editor: David Hyatt, Apple Inc http://www.apple.com/, hyatt@apple.com
Former Editor: Chris Marrin, Apple Inc http://www.apple.com/, cmarrin@apple.com
Former Editor: Aryeh Gregor, Mozilla http://www.mozilla.org/, ayg@aryeh.name
Abstract: CSS transforms allows elements styled with CSS to be transformed in two-dimensional space. This specification is the convergence of the <a href="https://www.w3.org/TR/css3-2d-transforms/">CSS 2D transforms</a> and <a href="https://www.w3.org/TR/2009/WD-SVG-Transforms-20090320/">SVG transforms</a> specifications.
!Issues List: <a href="https://github.com/w3c/csswg-drafts/issues?q=is%3Aissue+is%3Aopen+label%3Acss-transforms-1">in GitHub</a>
Ignored terms: calcMode, viewBox, baseVal, animVal
</pre>
<pre class=anchors>
text: transform; type: element-attr; for: ; spec: svg1.1; url: https://www.w3.org/TR/SVG11/coords.html#TransformAttribute
text: patternTransform; type: element-attr; for: pattern; spec: svg1.1; url: https://www.w3.org/TR/SVG11/pservers.html#PatternElementPatternTransformAttribute
text: patternUnits; type: element-attr; for: pattern; spec: svg1.1; url: https://www.w3.org/TR/SVG/pservers.html#PatternElementPatternUnitsAttribute
text: gradientTransform; type: element-attr; for: linearGradient; spec: svg1.1; url: https://www.w3.org/TR/SVG11/pservers.html#LinearGradientElementGradientTransformAttribute
text: gradientUnits; type: element-attr; for: linearGradient; spec: svg1.1; url: https://www.w3.org/TR/SVG/pservers.html#LinearGradientElementGradientUnitsAttribute
</pre>
<pre class='link-defaults'>
spec: css-text-3; type: property
text: text-align
text: letter-spacing
text: word-spacing
spec:css-display-3; type:property
text: display
spec:css-display-3; type:value; for:display
text: table-row
text: table-row-group
text: table-header-group
text: table-footer-group
text: table-cell
text: table-caption
spec:css-backgrounds-3; type:property
text: background-attachment
</pre>
<style type="text/css">
.example {
clear:both
}
th {
text-align:left
}
.pseudo-code {
font-family:monospace
}
.pseudo-code > ol {
list-style-type:decimal
}
.pseudo-code > ol > li > ol {
list-style-type:lower-latin
}
.pseudo-code > ol > li > ol > li > ol {
list-style-type:lower-roman
}
.pseudo-code ul {
list-style-type:disc
}
dd > p:nth-child(1) {
margin-top:0
}
</style>
Introduction {#intro}
=====================
<em>This section is not normative.</em>
The CSS <a href="https://www.w3.org/TR/CSS2/visuren.html">visual formatting model</a> describes a coordinate system within each element is positioned. Positions and sizes in this coordinate space can be thought of as being expressed in pixels, starting in the origin of point with positive values proceeding to the right and down.
This coordinate space can be modified with the 'transform' property. Using transform, elements can be translated, rotated and scaled.
Module Interactions {#module-interactions}
------------------------------------------
This module defines a set of CSS properties that affect the visual rendering of elements to which those properties are applied; these effects are applied after elements have been sized and positioned according to the <a href="https://www.w3.org/TR/CSS2/visuren.html">visual formatting model</a> from [[!CSS2]]. Some values of these properties result in the creation of a <a href="https://www.w3.org/TR/CSS2/visuren.html#containing-block">containing block</a>, and/or the creation of a <a spec="css21">stacking context</a>.
Transforms affect the rendering of backgrounds on elements with a value of ''fixed'' for the 'background-attachment' property, which is specified in [[!CSS3BG]].
Transforms affect the client rectangles returned by the Element Interface Extensions <a href="https://www.w3.org/TR/cssom-view/#dom-element-getclientrects">getClientRects()</a> and <a href="https://www.w3.org/TR/cssom-view/#dom-element-getboundingclientrect">getBoundingClientRect()</a>, which are specified in [[CSSOM-VIEW]].
Transforms affect the computation of the <a href="https://www.w3.org/TR/css-overflow-3/#scrollable-overflow-region">scrollable overflow region</a> as described by [[CSS-OVERFLOW-3]].
CSS Values {#css-values}
------------------------
This specification follows the <a href="https://www.w3.org/TR/CSS21/about.html#property-defs">CSS property definition conventions</a> from [[!CSS2]].
Value types not defined in this specification are defined in CSS Values & Units [[!CSS-VALUES-3]].
Other CSS modules may expand the definitions of these value types.
In addition to the property-specific values listed in their definitions,
all properties defined in this specification
also accept the <a>CSS-wide keywords</a> keywords as their property value.
For readability they have not been repeated explicitly.
Terminology {#terminology}
==========================
When used in this specification, terms have the meanings assigned in this section.
<div data-export>
: <dfn>transformable element</dfn>
:: A transformable element is an element in one of these categories:
* all elements whose layout is governed by the CSS box model except for non-replaced inline boxes, table-column boxes, and table-column-group boxes [[!CSS2]],
* all SVG <a>paint server elements</a> and SVG <a>renderable elements</a> with the exception of any descendant element of <a>text content elements</a> [[!SVG2]].
: <dfn>transformed element</dfn>
:: An element with a computed value other than ''transform/none'' for the 'transform' property.
: <dfn export>user coordinate system</dfn>
: <dfn export>local coordinate system</dfn>
:: In general, a coordinate system defines locations and distances on the current canvas. The current local coordinate system (also user coordinate system) is the coordinate system that is currently active and which is used to define how coordinates and lengths are located and computed, respectively, on the current canvas.
The current user coordinate system has its origin at the top-left of a [=reference box=] specified by the 'transform-box' property. Percentage values are relative to the dimension of this reference box. One unit equals one CSS pixel.
: <dfn>transformation matrix</dfn>
:: A matrix that defines the mathematical mapping from one coordinate system into another. It is computed from the values of the 'transform' and 'transform-origin' properties as described <a href="#transformation-matrix-computation">below</a>.
: <dfn>current transformation matrix</dfn> (CTM)
:: A matrix that defines the mapping from the [=local coordinate system=] into the [=viewport coordinate system=].
: <dfn>2D matrix</dfn>
:: A 3x2 transformation matrix, or a 4x4 matrix where the items m<sub>31</sub>, m<sub>32</sub>, m<sub>13</sub>, m<sub>23</sub>, m<sub>43</sub>, m<sub>14</sub>, m<sub>24</sub>, m<sub>34</sub> are equal to ''0'' and m<sub>33</sub>, m<sub>44</sub> are equal to ''1''.
: <dfn>identity transform function</dfn>
:: A <a href="#transform-functions">transform function</a> that is equivalent to a identity 4x4 matrix (see <a href="#mathematical-description">Mathematical Description of Transform Functions</a>). Examples for identity transform functions are ''translate(0)'', ''translateX(0)'', ''translateY(0)'', ''scale(1)'', ''scaleX(1)'', ''scaleY(1)'', ''rotate(0)'', ''skew(0, 0)'', ''skewX(0)'', ''skewY(0)'' and ''matrix(1, 0, 0, 1, 0, 0)''.
: <dfn>post-multiply</dfn>
: <dfn>post-multiplied</dfn>
:: Term <var>A</var> post-multiplied by term <var>B</var> is equal to <var>A</var> · <var>B</var>.
: <dfn>pre-multiply</dfn>
: <dfn>pre-multiplied</dfn>
:: Term <var>A</var> pre-multiplied by term <var>B</var> is equal to <var>B</var> · <var>A</var>.
: <dfn>multiply</dfn>
:: Multiply term <var>A</var> by term <var>B</var> is equal to <var>A</var> · <var>B</var>.
</div>
The Transform Rendering Model {#transform-rendering}
====================================================
<em>This section is normative.</em>
Specifying a value other than ''transform/none'' for the 'transform' property establishes a new [=local coordinate system=] at the element that it is applied to. The mapping from where the element would have rendered into that local coordinate system is given by the element's [=transformation matrix=]. Transformations are cumulative. That is, elements establish their local coordinate system within the coordinate system of their parent. From the perspective of the user, an element effectively accumulates all the 'transform' properties of its ancestors as well as any local transform applied to it. The accumulation of these transforms defines a [=current transformation matrix=] for the element.
The coordinate space is a coordinate system with two axes: the X axis increases horizontally to the right; the Y axis increases vertically downwards.
<p id="transformation-matrix-computation">
The [=transformation matrix=] is computed from the 'transform' and 'transform-origin' properties as follows:
1. Start with the identity matrix.
2. Translate by the computed X and Y of 'transform-origin'
3. Multiply by each of the transform functions in 'transform' property from left to right
4. Translate by the negated computed X and Y values of 'transform-origin'
Transforms apply to [=transformable elements=].
Note: Transformations do affect the visual rendering, but have no affect on the CSS layout other than affecting overflow. Transforms are also taken into account when computing client rectangles exposed via the Element Interface Extensions, namely <a href="https://www.w3.org/TR/cssom-view/#dom-element-getclientrects">getClientRects()</a> and <a href="https://www.w3.org/TR/cssom-view/#dom-element-getboundingclientrect">getBoundingClientRect()</a>, which are specified in [[CSSOM-VIEW]].
<div class="example">
<pre><code highlight=css>
div {
transform: translate(100px, 100px);
}
</code></pre>
This transform moves the element by 100 pixels in both the X and Y directions.
<div class="figure">
<img src="examples/translate1.svg" alt="The 100px translation in X and Y"
width="470" height="250">
</div>
</div>
<div class="example">
<pre><code highlight=css>
div {
height: 100px; width: 100px;
transform-origin: 50px 50px;
transform: rotate(45deg);
}
</code></pre>
The 'transform-origin' property moves the point of origin by 50 pixels in both the X and Y directions. The transform rotates the element clockwise by 45° about the point of origin. After all transform functions were applied, the translation of the origin gets translated back by -50 pixels in both the X and Y directions.
<div class="figure">
<img alt="The point of origin gets translated temporary" src="examples/origin1.svg" width="735" height="250">
</div>
</div>
<div class="example">
<pre><code highlight=css>
div {
height: 100px; width: 100px;
transform: translate(80px, 80px) scale(1.5, 1.5) rotate(45deg);
}
</code></pre>
The visual appareance is as if the <a element>div</a> element gets translated by 80px to the bottom left direction, then scaled up by 150% and finally rotated by 45°.
Each <<transform-function>> can get represented by a corresponding 4x4 matrix. To map a point from the coordinate space of the <a element>div</a> box to the coordinate space of the parent element, these transforms get multiplied in the reverse order:
1. The rotation matrix gets <a>post-multiplied</a> by the scale matrix.
2. The result of the previous multiplication is then <a>post-multiplied</a> by the translation matrix to create the accumulated transformation matrix.
3. Finally, the point to map gets <a>pre-multiplied</a> with the accumulated transformation matrix.
For more details see <a href="#transform-function-lists">The Transform Function Lists</a>.
<div class="figure">
<img src="examples/compound_transform.svg" alt="The transform specified above" width="270" height="270">
</div>
Note: The identical rendering can be obtained by nesting elements with the equivalent transforms:
<pre><code highlight=html>
<div style="transform: translate(80px, 80px)">
<div style="transform: scale(1.5, 1.5)">
<div style="transform: rotate(45deg)"></div>
</div>
</div>
</code></pre>
</div>
For elements whose layout is governed by the CSS box model, the transform property does not affect the flow of the content surrounding the transformed element. However, the extent of the overflow area takes into account transformed elements. This behavior is similar to what happens when elements are offset via relative positioning. Therefore, if the value of the 'overflow' property is ''overflow/scroll'' or ''overflow/auto'', scrollbars will appear as needed to see content that is transformed outside the visible area. Specifically, transforms can extend (but do not shrink) the size of the overflow area, which is computed as the union of the bounds of the elements before and after the application of transforms.
For elements whose layout is governed by the CSS box model, any value other than ''transform/none'' for the transform results in the creation of a stacking context. Implementations must paint the layer it creates, within its parent stacking context, at the same stacking order that would be used if it were a positioned element with ‘z-index: 0’. If an element with a transform is positioned, the ‘z-index’ property applies as described in [[!CSS2]], except that ‘auto’ is treated as ‘0’ since a new stacking context is always created
For elements whose layout is governed by the CSS box model, any value other than ''transform/none'' for the transform also causes the element to become a containing block, and the object acts as a containing block for fixed positioned descendants.
Issue(w3c/csswg-drafts#913): Is this effect on ''position: fixed'' necessary? If so, need to go into more detail here about why fixed positioned objects should do this, i.e., that it's much harder to implement otherwise.
<a href="https://www.w3.org/TR/css3-background/#fixed0">Fixed backgrounds</a> on the root element are affected by any transform specified for that element. For all other elements that are effected by a transform (i.e. have a transform applied to them, or to any of their ancestor elements), a value of ''fixed'' for the 'background-attachment' property is treated as if it had a value of ''background-attachment/scroll''. The computed value of 'background-attachment' is not affected.
Note: If the root element is transformed, the transformation applies to the entire canvas, including any background specified for the root element. Since <a href="https://www.w3.org/TR/css3-background/#special-backgrounds">the background painting area for the root element</a> is the entire canvas, which is infinite, the transformation might cause parts of the background that were originally off-screen to appear. For example, if the root element's background were repeating dots, and a transformation of ''scale(0.5)'' were specified on the root element, the dots would shrink to half their size, but there will be twice as many, so they still cover the whole viewport.
The 'transform' Property {#transform-property}
==============================================
A transformation is applied to the coordinate system an element renders into through the 'transform' property. This property contains a list of <a href="#transform-functions">transform functions</a>. The final transformation value for a coordinate system is obtained by converting each function in the list to its corresponding matrix like defined in <a href="#mathematical-description">Mathematical Description of Transform Functions</a>, then multiplying the matrices.
<pre class='propdef'>
Name: transform
Value: none | <<transform-list>>
Initial: none
Applies to: [=transformable elements=]
Inherited: no
Percentages: refer to the size of [=reference box=]
Computed value: As specified, but with relative lengths converted into absolute lengths.
Media: visual
Animatable: as <a href="#interpolation-of-transforms">transform</a>
</pre>
Any computed value other than ''transform/none'' for the transform affects containing block and stacking context, as described in [[#transform-rendering]].
<pre class=prod><dfn><transform-list></dfn> = <<transform-function>>+</pre>
Serialization of <<transform-function>>s {#serialization-of-transform-functions}
----------------------------------------
To serialize the <<transform-function>>s, serialize as per their individual grammars, in the order the grammars are written in, avoiding <<calc()>> expressions where possible, avoiding <<calc()>> transformations, omitting components when possible without changing the meaning, joining space-separated tokens with a single space, and following each serialized comma with a single space.
Serialization of the computed value of <<transform-list>> {#serialization-of-the-computed-value}
----------------------------------------------------------------
A <<transform-list>> for the computed value is serialized to one <<matrix()>> function by the following algorithm:
<ol class="algorithm">
1. Let <var>transform</var> be a 4x4 matrix initialized to the identity matrix. The elements <var ignore> m11</var>, <var ignore>m22</var>, <var ignore>m33</var> and <var ignore>m44</var> of <var>transform</var> must be set to ''1'' all other elements of <var>transform</var> must be set to ''0''.
2. Post-multiply all <<transform-function>>s in <<transform-list>> to <var>transform</var>.
3. Serialize <var>transform</var> to a <<matrix()>> function.
</ol>
The 'transform-origin' Property {#transform-origin-property}
============================================================
<pre class='propdef'>
Name: transform-origin
Value: [ left | center | right | top | bottom | <<length-percentage>> ]<br> | <br> [ left | center | right | <<length-percentage>> ]<br> [ top | center | bottom | <<length-percentage>> ] <<length>>?<br> |<br> [[ center | left | right ] && [ center | top | bottom ]] <<length>>?
Initial: 50% 50%
Applies to: [=transformable elements=]
Inherited: no
Percentages: refer to the size of [=reference box=]
Computed value: For <<length>> the absolute value, otherwise a percentage
Media: visual
Animatable: as <a href="https://drafts.csswg.org/css3-transitions/#animtype-simple-list">simple list</a> of <a href="https://drafts.csswg.org/css3-transitions/#animtype-lpcalc">length, percentage, or calc</a>
</pre>
The values of the 'transform' and 'transform-origin' properties are used to compute the [=transformation matrix=], as described above.
If only one value is specified, the second value is assumed to be <a value for=transform-origin>center</a>. If one or two values are specified, the third value is assumed to be ''0px''.
If two or more values are defined and either no value is a keyword, or the only used keyword is <a value for=transform-origin>center</a>, then the first value represents the horizontal position (or offset) and the second represents the vertical position (or offset). A third value always represents the Z position (or offset) and must be of type <<length>>.
<dl dfn-for="transform-origin" dfn-type="value">
: <<length-percentage>>
:: A percentage for the horizontal offset is relative to the width of the [=reference box=]. A percentage for the vertical offset is relative to the height of the [=reference box=]. The value for the horizontal and vertical offset represent an offset from the top left corner of the [=reference box=].
: <<length>>
:: A length value gives a fixed length as the offset. The value for the horizontal and vertical offset represent an offset from the top left corner of the [=reference box=].
: <dfn>top</dfn>
:: Computes to ''0%'' for the vertical position.
: <dfn>right</dfn>
:: Computes to ''100%'' for the horizontal position.
: <dfn>bottom</dfn>
:: Computes to ''100%'' for the vertical position.
: <dfn>left</dfn>
:: Computes to ''0%'' for the horizontal position.
: <dfn>center</dfn>
:: Computes to ''50%'' (''left 50%'') for the horizontal position if the horizontal position is not otherwise specified, or ''50%'' (''top 50%'') for the vertical position if it is.
</dl>
For SVG elements without associated CSS layout box the initial [=used value=] is ''0 0'' as if the user agent style sheet contained:
<pre><code highlight=css>
*:not(svg), *:not(foreignObject) > svg {
transform-origin: 0 0;
}
</code></pre>
The 'transform-origin' property is a <a>resolved value special case property</a> like 'height'. [[!CSSOM]]
Transform reference box: the 'transform-box' property {#transform-box}
======================================================================
<pre class='propdef'>
Name: transform-box
Value: border-box | fill-box | view-box
Initial: view-box
Applies to: [=transformable elements=]
Inherited: no
Percentages: N/A
Computed value: Same as specified value.
Media: visual
Animatable: no
</pre>
All transformations defined by the 'transform' and 'transform-origin' property are relative to the position and dimensions of the <dfn>reference box</dfn> of the element. The [=reference box=] is specified by one of the following:
<dl dfn-for=transform-box>
: <dfn dfn-type=value>border-box</dfn>
:: Uses the border box as reference box. The reference box of a table is the border box of its <a href="https://www.w3.org/TR/CSS21/tables.html#model">table wrapper box</a>, not its table box.
: <dfn dfn-type=value>fill-box</dfn>
:: Uses the <a>object bounding box</a> as reference box.
: <dfn dfn-type=value>view-box</dfn>
:: Uses the nearest <a href="https://www.w3.org/TR/SVG11/intro.html#TermSVGViewport">SVG viewport</a> as reference box.
If a {{viewBox}} attribute is specified for the <a href="https://www.w3.org/TR/SVG11/intro.html#TermSVGViewport">SVG viewport</a> creating element:
* The reference box is positioned at the origin of the coordinate system established by the {{viewBox}} attribute.
* The dimension of the reference box is set to the <em>width</em> and <em>height</em> values of the {{viewBox}} attribute.
Issue(w3c/csswg-drafts#999): Follow used value definition of Fill and Stroke specs/SVG2?
</dl>
Issue(w3c/csswg-drafts#892): Clarify what the reference box of paint servers, <a element>clipPath</a> and <a element>mask</a> is.
A reference box adds an additional offset to the origin specified by the 'transform-origin' property.
For SVG elements without an associated CSS layout box, the [=used value=] for ''transform-box/border-box'' is ''transform-box/view-box''.
For elements with an associated CSS layout box, the [=used value=] for ''transform-box/fill-box'' and ''transform-box/view-box'' is ''transform-box/border-box''.
The SVG <a element-attr for>transform</a> Attribute {#svg-transform}
====================================================================
SVG presentation attributes {#transform-attribute-specificity}
--------------------------------------------------------------
The 'transform-origin' CSS property is also a <a>presentation attribute</a> and extends the list of existing <a>presentation attributes</a> [[!SVG2]].
SVG 2 defines the <a element-attr for>transform</a>, <{pattern/patternTransform}>, <{linearGradient/gradientTransform}> attributes as <a>presentation attributes</a>, represented by the CSS 'transform' property [[!SVG2]].
The participation in the CSS cascade is determined by the specificity of <a>presentation attributes</a> in the SVG specification. According to SVG, user agents conceptually insert a <a href="https://www.w3.org/TR/SVG/styling.html#UsingPresentationAttributes">new author style sheet</a> for presentation attributes, which is the first in the author style sheet collection [[!SVG2]].
<div class="example">
This example shows the combination of the 'transform' style property and the <a element-attr for>transform</a> attribute.
<pre><code highlight=xml>
<svg xmlns="http://www.w3.org/2000/svg">
<style>
.container {
transform: translate(100px, 100px);
}
</style>
<g class="container" transform="translate(200 200)">
<rect width="100" height="100" fill="blue" />
</g>
</svg>
</code></pre>
<div class="figure">
<img src="examples/svg-translate1.svg" width="470" height="240" alt="Translated SVG container element.">
</div>
Because of the participation to the CSS cascade, the 'transform' style property overrides the <a element-attr for>transform</a> attribute. Therefore the container gets translated by ''100px'' in both the horizontal and the vertical directions, instead of ''200px''.
</div>
Syntax of the SVG <a element-attr for>transform</a> attribute {#svg-syntax}
---------------------------------------------------------------------------
For backwards compatibility reasons, the syntax of the <a element-attr for>transform</a>, <{pattern/patternTransform}>, <{linearGradient/gradientTransform}> attributes differ from the syntax of the 'transform' CSS property. For the attributes, there is no support for additional <<transform-function>>s defined for the CSS 'transform' property. Specifically, <<translateX()>>, <<translateY()>>, <<scaleX()>>, <<scaleY()>> and <<skew()>> are not supported by the <a element-attr for>transform</a>, <{pattern/patternTransform}>, <{linearGradient/gradientTransform}> attributes.
The following list uses the Backus-Naur Form (BNF) to define values for the <a element-attr for>transform</a>, <a element-attr for>patternTransform</a> and <a element-attr for>gradientTransform</a> attributes followed by an informative rail road diagram. The following notation is used:
* *: 0 or more
* +: 1 or more
* ?: 0 or 1
* (): grouping
* |: separates alternatives
* double quotes surround literals. Literals consists of <a>letter</a>s [[!CSS-SYNTAX-3]], left parenthesis and right parenthesis.
* <<number-token>> defined by the CSS Syntax module [[!CSS-SYNTAX-3]].
Note: The syntax reflects implemented behavior in user agents and differs from the syntax defined by SVG 1.1.
<dl>
<dt>left parenthesis (</dt>
<dd>U+0028 LEFT PARENTHESIS</dd>
<dt>right parenthesis )</dt>
<dd>U+0029 RIGHT PARENTHESIS</dd>
<dt id="svg-comma">comma</dt>
<dd>U+002C COMMA.
<dt id="svg-wsp">wsp</dt>
<dd>Either a U+000A LINE FEED, U+000D CARRIAGE RETURN, U+0009 CHARACTER TABULATION, or U+0020 SPACE.
<dd>
<pre class='railroad'>
Choice:
T: space
T: \t
T: \r
T: \f
</pre>
</dd>
<dt id="svg-comma-wsp">comma-wsp</dt>
<dd><pre>(wsp+ comma? wsp*) | (comma wsp*)</pre></dd>
<dd>
<pre class='railroad'>
Choice:
Seq:
Plus:
N: wsp
Optional:
N: comma
Star:
N: wsp
Seq:
N: comma
Star:
N: wsp
</pre>
</dd>
<dt id="svg-translate">translate</dt>
<dd><pre>"translate" wsp* "(" wsp* number ( comma-wsp? number )? wsp* ")"</pre></dd>
<dd>
<pre class='railroad'>
Stack:
Seq:
T: translate
Star:
N: wsp
T: (
Star:
N: wsp
Seq:
N: <number-token>
Optional:
Seq:
Optional:
N: comma-wsp
N: <number-token>
Seq:
Star:
N: wsp
T: )
</pre>
</dd>
<dt id="svg-scale">scale</dt>
<dd><pre>"scale" wsp* "(" wsp* number ( comma-wsp? number )? wsp* ")"</pre></dd>
<dd>
<pre class='railroad'>
Stack:
Seq:
T: scale
Star:
N: wsp
T: (
Star:
N: wsp
Seq:
N: <number-token>
Optional:
Seq:
Optional:
N: comma-wsp
N: <number-token>
Seq:
Star:
N: wsp
T: )
</pre>
</dd>
<dt id="svg-rotate">rotate</dt>
<dd><pre>"rotate" wsp* "(" wsp* number ( comma-wsp? number comma-wsp? number )? wsp* ")"</pre></dd>
<dd>
<pre class='railroad'>
Stack:
Seq:
T: rotate
Star:
N: wsp
T: (
Star:
N: wsp
Seq:
N: <number-token>
Optional:
Plus:
Seq:
Optional:
N: comma-wsp
N: <number-token>
C: 1
Seq:
Star:
N: wsp
T: )
</pre>
</dd>
<dt id="svg-skewX">skewX</dt>
<dd><pre>"skewY" wsp* "(" wsp* number wsp* ")"</pre></dd>
<dd>
<pre class='railroad'>
Stack:
Seq:
T: skewX
Star:
N: wsp
T: (
Star:
N: wsp
Seq:
N: <number-token>
Seq:
Star:
N: wsp
T: )
</pre>
</dd>
<dt id="svg-skewY">skewY</dt>
<dd><pre>"skewY" wsp* "(" wsp* number wsp* ")"</pre></dd>
<dd>
<pre class='railroad'>
Stack:
Seq:
T: skewX
Star:
N: wsp
T: (
Star:
N: wsp
Seq:
N: <number-token>
Seq:
Star:
N: wsp
T: )
</pre>
</dd>
<dt id="svg-matrix">matrix</dt>
<dd><pre>
"matrix" wsp* "(" wsp*
number comma-wsp?
number comma-wsp?
number comma-wsp?
number comma-wsp?
number comma-wsp?
number wsp* ")"
</pre></dd>
<dd>
<pre class='railroad'>
Stack:
Seq:
T: matrix
Star:
N: wsp
T: (
Star:
N: wsp
Seq:
N: <number-token>
Optional:
Plus:
Seq:
Optional:
N: comma-wsp
N: <number-token>
C: 4
Seq:
Star:
N: wsp
T: )
</pre>
</dd>
<dt id="svg-transform-function">transform</dt>
<dd><pre>
matrix
| translate
| scale
| rotate
| skewX
| skewY
</pre></dd>
<dd>
<pre class='railroad'>
Choice:
N: translate
N: scale
N: rotate
N: skewX
N: skewY
N: matrix
</pre>
</dd>
<dt id="svg-transforms">transforms</dt>
<dd><pre>
transform
| transform comma-wsp transforms
</dd></pre>
<dd>
<pre class='railroad'>
Choice:
N: transform
Seq:
N: transform
N: comma-wsp
N: transforms
</pre>
</dd>
<dt id="svg-transform-list">transform-list</dt>
<dd><pre>wsp* transforms? wsp*</pre></dd>
<dd>
<pre class='railroad'>
Star:
N: wsp
Optional:
N: transforms
Star:
N: wsp
</pre>
</dd>
</dl>
SVG transform functions {#svg-transform-functions}
--------------------------------------------------
SVG transform functions of the <a element-attr for>transform</a>, <{pattern/patternTransform}>, <{linearGradient/gradientTransform}> attributes defined by the syntax above are mapped to CSS <<transform-function>>s as follows:
<table class="data" id="term-matching">
<thead>
<tr>
<th>SVG transform function
<th>CSS <<transform-function>>
<th>Additional notes
</tr>
</thead>
<tbody>
<tr>
<th><a href="#svg-translate">translate</a>
<td><<translate()>>
<td>Number values interpreted as CSS <<length>> types with ''px'' units.
</tr>
<tr>
<th><a href="#svg-scale">scale</a>
<td><<scale()>>
<td>
</tr>
<tr>
<th><a href="#svg-rotate">rotate</a>
<td><<rotate()>>
<td>Only single value version. Number value interpreted as CSS <<angle>> type with ''deg'' unit.
</tr>
<tr>
<th><a href="#svg-skewX">skewX</a>
<td><<skewX()>>
<td>Number value interpreted as CSS <<angle>> type with ''deg'' unit.
</tr>
<tr>
<th><a href="#svg-skewY">skewY</a>
<td><<skewY()>>
<td>Number value interpreted as CSS <<angle>> type with ''deg'' unit.
</tr>
<tr>
<th><a href="#svg-matrix">matrix</a>
<td><<matrix()>>
<td>
</tr>
</tbody>
</table>
The SVG transform function <a href="#svg-rotate">rotate</a> with 3 values can not be mapped to a corresponding CSS <<transform-function>>. The 2 optional number values represent a horizontal translation value ''cx'' followed by a vertical translation value ''cy''. Both number values get interpreted as CSS <<length>> types with ''px'' units and define the origin for rotation. The behavior is equivalent to an initial translation by ''cx'', ''cy'', a rotation defined by the first number value interpreted as <<angle>> type with ''deg'' unit followed by a translation by ''-cx'', ''-cy''.
If the value of a <a element-attr for>transform</a> attribute is the start or end value of a CSS Transition and the SVG <a href="svg-transform-list">transform list</a> contains at least one <a href="#svg-rotate">rotate</a> transform function with 3 values, the individual SVG transform functions must get <a>post-multiplied</a> and the resulting matrix must get mapped to a <<matrix()>> CSS <<transform-function>> and used as start/end value of the CSS Transition.
Issue(w3c/csswg-drafts#2684): Implementations differ. More testing is required.
User coordinate space {#svg-user-coordinate-space}
--------------------------------------------------
For the <{pattern}>, <{linearGradient}>, <{radialGradient}> and <{clipPath}> elements the <a element-attr for>transform</a>, <{pattern/patternTransform}>, <{linearGradient/gradientTransform}> attributes represents values in the current user coordinate system in place at the time when these elements are referenced (i.e., the user coordinate system for the element referencing the <{pattern}> element via a 'fill' or 'stroke' property). Percentage values are relative to the [=reference box=] of the referencing element.
In particular the <{pattern/patternUnits}>, <{linearGradient/gradientUnits}> and <{mask/maskUnits}> attributes don't affect the user coordinate system used for transformations [[SVG11]].
For all other [=transformable elements=] the <a element-attr for>transform</a> attribute represents values in the current user coordinate system of the parent. All percentage values of the <a element-attr for>transform</a> attribute are relative to the element's [=reference box=].
Issue(w3c/csswg-drafts#893): User coordinate space statement breaks SVG.
<div class="example">
The 'transform-origin' property on the pattern in the following example specifies a ''50%'' translation of the origin in the horizontal and vertical dimension. The 'transform' property specifies a translation as well, but in absolute lengths.
<pre><code highlight=xml>
<svg xmlns="http://www.w3.org/2000/svg">
<style>
pattern {
transform: rotate(45deg);
transform-origin: 50% 50%;
}
</style>
<defs>
<pattern id="pattern-1">
<rect id="rect1" width="100" height="100" fill="blue" />
</pattern>
</defs>
<rect width="200" height="200" fill="url(#pattern-1)" />
</svg>
</code></pre>
An SVG <{pattern}> element doesn't have a bounding box. The [=reference box=] of the referencing <{rect}> element is used instead to solve the relative values of the 'transform-origin' property. Therefore the point of origin will get translated by 100 pixels temporarily to rotate the user space of the <{pattern}> elements content.
</div>
SVG DOM interface for the <a element-attr for>transform</a> attribute {#transform-attribute-dom}
------------------------------------------------------------------------------------------------
The SVG specification defines the "<a href="https://www.w3.org/TR/2011/REC-SVG11-20110816/coords.html#InterfaceSVGAnimatedTransformList">SVGAnimatedTransformList</a>" interface in the SVG DOM to provide access to the animated and the base value of the SVG <a element-attr for>transform</a>, <{linearGradient/gradientTransform}> and <{pattern/patternTransform}> attributes. To ensure backwards compatibility, this API must still be supported by user agents.
{{baseVal}} gives the author the possibility to access and modify the values of the SVG <a element-attr for>transform</a>, <{pattern/patternTransform}>, <{linearGradient/gradientTransform}> attributes. To provide the necessary backwards compatibility to the SVG DOM, {{baseVal}} must reflect the values of this author style sheet. All modifications to SVG DOM objects of {{baseVal}} must affect this author style sheet immediately.
{{animVal}} represents the computed style of the 'transform' property. Therefore it includes all applied <a href="https://www.w3.org/TR/css3-transitions/">CSS3 Transitions</a>, <a href="https://www.w3.org/TR/css3-animations/">CSS3 Animations</a> or <a href="#svg-animation">SVG Animations</a> if any of those are underway. The computed style and SVG DOM objects of {{animVal}} can not be modified.
SVG Animation {#svg-animation}
=============
The <{animate}> and <{set}> element {#svg-animate-element}
-----------------------------------
With this specification, the <{animate}> element and the <{set}> element can animate the data type <<transform-list>>.
The animation effect is <a>post-multiplied</a> to the underlying value for additive <{animate}> animations (see below) instead of added to the underlying value, due to the specific behavior of <<transform-list>> animations.
<var ignore=''>From-to</var>, <var ignore=''>from-by</var> and <var ignore=''>by</var> animations are defined in SMIL to be equivalent to a corresponding <var ignore>values</var> animation. However, <var ignore=''>to</var> animations are a mixture of additive and non-additive behavior [[SMIL3]].
<var ignore=''>To</var> animations on <{animate}> provide specific functionality to get a smooth change from the underlying value to the <var ignore=''>to</var> attribute value, which conflicts mathematically with the requirement for additive transform animations to be <a>post-multiplied</a>. As a consequence, the behavior of <var ignore=''>to</var> animations for <{animate}> is undefined. Authors are suggested to use <var ignore=''>from-to</var>, <var ignore=''>from-by</var>, <var ignore=''>by</var> or <var ignore=''>values</var> animations to achieve any desired transform animation.
The value "paced" is undefined for the attribute <{animate/calcMode}> on <{animate}> for animations of the data type <<transform-list>>. If specified, UAs may choose the value "linear" instead. Future versions of this specification may define how paced animations can be performed on <<transform-list>>.
Note: The following paragraphs extend <a href="https://www.w3.org/TR/SVG/animate.html#complexDistances">Elements, attributes and properties that can be animated</a> [[SVG11]].
The introduced presentation attributes <a element-attr for>transform</a>, <{pattern/patternTransform}>, <{linearGradient/gradientTransform}> and 'transform-origin' are animatable.
With this specification the SVG basic data type <<transform-list>> is equivalent to a list of <<transform-function>>s. <<transform-list>> is animatable and additive. The data type can be animated using the SVG <{animate}> element and the SVG <{set}> element. SVG animations must run the same animation steps as described in section <a href="#interpolation-of-transforms">Transitions and Animations between Transform Values</a>.
<table class="data">
<caption>Animatable data types</caption>
<thead>
<tr>
<th>Data type
<th>Additive?
<th><{animate}>
<th><{set}>
<th><{animateColor}>
<th><{animateTransform}>
<th>Notes
</thead>
<tbody>
<tr>
<th><<transform-list>>
<td>yes
<td>yes
<td>yes
<td>no
<td>yes
<td>Additive for <{animateTransform}> means that a transformation is <a>post-multiplied</a> to the base set of transformations.
</tbody>
</table>
Neutral element for addition {#neutral-element}
----------------------------
Some animations require a neutral element for addition. For transform functions this is a scalar or a list of scalars of 0. Examples of neutral elements for transform functions are ''translate(0)'', ''scale(0)'', ''rotate(0)'', ''skewX(0)'', ''skewY(0)''.
Note: This paragraph focuses on the requirements of [[SMIL]] and the extension defined by [[SVG11]]. This specification does not provide definitions of neutral elements for the other transform functions than the functions listed above.
<div class="example">
A <var>by</var> animation with a by value v<sub>b</sub> is equivalent to the same animation with a values list with 2 values, the neutral element for addition for the domain of the target attribute (denoted 0) and v<sub>b</sub>, and ''additive="sum"''. [[SMIL3]]
<pre><code highlight=xml>
<rect width="100" height="100">
<animateTransform attributeName="transform" attributeType="XML"
type="scale" by="1" dur="5s" fill="freeze"/>
</rect>
</code></pre>
The neutral element for addition when performing a <var>by</var> animation with ''type="scale"'' is the value 0. Thus, performing the animation of the example above causes the rectangle to be invisible at time 0s (since the animated transform list value is ''scale(0)''), and be scaled back to its original size at time 5s (since the animated transform list value is ''scale(1)'').
</div>
The SVG '<a href="https://www.w3.org/TR/SVG/animate.html#TargetAttributes">attributeName</a>' attribute {#svg-attribute-name}
-------------------------------------------------------------------------------------------------------
<a href="https://www.w3.org/TR/SVG/animate.html">SVG 1.1 Animation</a> defines the "<a href="https://www.w3.org/TR/SVG/animate.html#TargetAttributes">attributeName</a>" attribute to specify the name of the target attribute. For the presentation attributes <{linearGradient/gradientTransform}> and <{pattern/patternTransform}> it will also be possible to use the value 'transform'. The same 'transform' property will get animated.
<div class="example">
In this example the gradient transformation of the linear gradient gets animated.
<pre><code highlight=xml>
<linearGradient gradientTransform="scale(2)">
<animate attributeName="gradientTransform" from="scale(2)" to="scale(4)"
dur="3s" additive="sum"/>
<animate attributeName="transform" from="translate(0, 0)" to="translate(100px, 100px)"
dur="3s" additive="sum"/>
</linearGradient>
</code></pre>
The <{linearGradient}> element specifies the <{linearGradient/gradientTransform}> presentation attribute. The two <{animate}> elements address the target attribute <{linearGradient/gradientTransform}> and 'transform'. Even so all animations apply to the same gradient transformation by taking the value of the <{linearGradient/gradientTransform}> presentation attribute, applying the scaling of the first animation and applying the translation of the second animation one after the other.
</div>
The Transform Functions {#transform-functions}
==============================================
The value of the 'transform' property is a list of <dfn><transform-function></dfn>.
The set of allowed transform functions is given below.
In the following functions,
a <<zero>> behaves the same as ''0deg''
("unitless 0" angles are preserved for legacy compat).
A percentage for horizontal translations is relative to the width of the [=reference box=].
A percentage for vertical translations is relative to the height of the [=reference box=].
2D Transform Functions {#two-d-transform-functions}
----------------------
<dl dfn-for=transform>
: <span class='prod'><dfn>matrix()</dfn> = matrix( <<number>> [, <<number>> ]{5,5} )</span>
:: specifies a 2D transformation in the form of a <a href="#MatrixDefined">transformation matrix</a> of the six values a, b, c, d, e, f.
: <span class='prod'><dfn>translate()</dfn> = translate( <<length-percentage>> [, <<length-percentage>> ]? )</span>
:: specifies a <a href="#TranslateDefined">2D translation</a> by the vector [tx, ty], where tx is the first translation-value parameter and ty is the optional second translation-value parameter. If <em><ty></em> is not provided, ty has zero as a value.
: <span class='prod'><dfn>translateX()</dfn> = translateX( <<length-percentage>> )</span>
:: specifies a <a href="#TranslateDefined">translation</a> by the given amount in the X direction.
: <span class='prod'><dfn>translateY()</dfn> = translateY( <<length-percentage>> )</span>
:: specifies a <a href="#TranslateDefined">translation</a> by the given amount in the Y direction.
: <span class='prod'><dfn>scale()</dfn> = scale( <<number>> [, <<number>> ]? )</span>
:: specifies a <a href="#ScaleDefined">2D scale</a> operation by the [sx,sy] scaling vector described by the 2 parameters. If the second parameter is not provided, it takes a value equal to the first. For example, scale(1, 1) would leave an element unchanged, while scale(2, 2) would cause it to appear twice as long in both the X and Y axes, or four times its typical geometric size.
: <span class='prod'><dfn>scaleX()</dfn> = scaleX( <<number>> )</span>
:: specifies a <a href="#ScaleDefined">2D scale</a> operation using the [sx,1] scaling vector, where sx is given as the parameter.
: <span class='prod'><dfn>scaleY()</dfn> = scaleY( <<number>> )</span>
:: specifies a <a href="#ScaleDefined">2D scale</a> operation using the [1,sy] scaling vector, where sy is given as the parameter.
: <span class='prod'><dfn>rotate()</dfn> = rotate( [ <<angle>> | <<zero>> ] )</span>
:: specifies a <a href="#RotateDefined">2D rotation</a> by the angle specified in the parameter about the origin of the element, as defined by the 'transform-origin' property. For example, ''rotate(90deg)'' would cause elements to appear rotated one-quarter of a turn in the clockwise direction.
: <span class='prod'><dfn>skew()</dfn> = skew( [ <<angle>> | <<zero>> ] [, [ <<angle>> | <<zero>> ] ]? )</span>
:: specifies a <a href="#SkewDefined">2D skew</a> by [ax,ay] for X and Y. If the second parameter is not provided, it has a zero value.
Advisement: ''skew()'' exists for compatibility reasons, and should not be used in new content. Use ''skewX()'' or ''skewY()'' instead, noting that the behavior of ''skew()'' is different from multiplying ''skewX()'' with ''skewY()''.
: <span class='prod'><dfn>skewX()</dfn> = skewX( [ <<angle>> | <<zero>> ] )</span>
:: specifies a <a href="#SkewXDefined">2D skew transformation along the X axis</a> by the given angle.
: <span class='prod'><dfn>skewY()</dfn> = skewY( [ <<angle>> | <<zero>> ] )</span>
:: specifies a <a href="#SkewYDefined">2D skew transformation along the Y axis</a> by the given angle.
</dl>
Transform function primitives and derivatives {#transform-primitives}
---------------------------------------------
Some transform functions can be represented by more generic transform functions. These transform functions are called derived transform functions, and the generic transform functions are called primitive transform functions. Two-dimensional primitives and their derived transform functions are:
<dl>
<dt id="translate-primitive">''translate()''
<dd>for <<translateX()>>, <<translateY()>> and <<translate()>>.
<dt id="rotate-three-primitive">''rotate()'' with three arguments
<dd>for <<rotate()>> with one or three arguments if <a href="#svg-transform-functions">rotate with three arguments</a> is supported.
<dt id="scale-primitive">''scale()''
<dd>for <<scaleX()>>, <<scaleY()>> and <<scale()>>.
</dl>
The Transform Function Lists {#transform-function-lists}
========================================================
If a list of <<transform-function>> is provided, then the net effect is as if each transform function had been specified separately in the order provided. For example,
<pre><code highlight=html>
<div style="transform: translate(-10px,-20px) scale(2) rotate(45deg) translate(5px,10px)"/>
</code></pre>
is functionally equivalent to:
<pre><code highlight=html>
<div style="transform: translate(-10px,-20px)" id="root">
<div style="transform: scale(2)">
<div style="transform: rotate(45deg)">
<div style="transform: translate(5px,10px)" id="child">
</div>
</div>
</div>
</div>
</code></pre>
That is, in the absence of other styling that affects position and dimensions, a nested set of transforms is equivalent to a single list of transform functions, applied from the top ancestor (with the id <code>root</code>) to the deepest descendant (with the id <code>child</code>). The resulting transform is the matrix multiplication of the list of transforms.
Issue(w3c/csswg-drafts#909): Backport point mapping from one coordinate space to another from SVG.
If a transform function causes the [=current transformation matrix=] of an object to be non-invertible, the object and its content do not get displayed.
<div class="example">
The object in the following example gets scaled by 0.
<pre><code highlight=html>
<style>
.box {
transform: scale(0);
}
</style>
<div class="box">
Not visible
</div>
</code></pre>
The scaling causes a non-invertible CTM for the coordinate space of the div box. Therefore neither the div box, nor the text in it get displayed.
</div>
Interpolation of Transforms {#interpolation-of-transforms}
==========================================================
When animating or transitioning transforms, the transform function lists must be interpolated. For interpolation between one transform <em>from-transform</em> and a second transforms <em>to-transform</em>, the rules described below are applied.
<ul>
<li id="none-none-animation">
If both the <em>from-</em> and <em>to-transform</em> are ''transform/none'':
* There is no interpolation necessary. The computed value stays ''transform/none''.
<li id="none-transform-animation">
If one of the <em>from-</em> or <em>to-transforms</em> is ''transform/none'':
* The value ''transform/none'' is replaced by an equivalent [=identity transform function=] list for the corresponding transform function list. Both transform function lists get interpolated following the next rule.
<div class="example">
For example, if <em>from-transform</em> is ''scale(2)'' and <em>to-transform</em> is ''transform/none'' then the value ''scale(1)'' will be used for <em>to-transform</em> and animation will proceed using the next rule. Similarly, if <em>from-transform</em> is ''transform/none'' and <em>to-transform</em> is ''scale(2) rotate(50deg)'' then the animation will execute as if <em>from-transform</em> is ''scale(1) rotate(0)''.