Skip to content

Commit 29f59cf

Browse files
trchen1033Tien Ren Chen
authored and
Tien Ren Chen
committed
[css-transform] Define "containing block for all descendants"
Add a new definition "containing block for all descendants" and specify that values other than 'none' on 'transform', 'transform-style', 'perspective' will cause an element to establish a containg block for all descendants.
1 parent ee1d857 commit 29f59cf

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

css-transforms-1/Overview.bs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,46 @@ For elements whose layout is governed by the CSS box model, the transform proper
316316

317317
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 ''z-index/auto'' is treated as ''0'' since a new stacking context is always created.
318318

319-
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.
319+
For elements whose layout is governed by the CSS box model, any value other than ''transform/none'' for the transform also causes the element's padding box to form a containing block for all of its out-of-flow descendants, including both absolute-position and fixed-position descendants, and fixed background attachments on descendants and itself.
320320

321-
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.
321+
<div class="example">
322+
An element with 'transform' other than ''transform/none'' establishes <dfn export>containing block for all descendants</dfn>. To demostrate the effect on fixed-position descendants, the following code snippets should behave identically:
323+
<pre>
324+
&lt;style>
325+
#container {
326+
width: 300px;
327+
height: 200px;
328+
border: 5px dashed black;
329+
padding: 5px;
330+
overflow: scroll;
331+
}
332+
333+
#bloat {
334+
height: 1000px;
335+
}
336+
337+
#child {
338+
right: 0;
339+
bottom: 0;
340+
width: 10%;
341+
height: 10%;
342+
background: green;
343+
}
344+
&lt;/style>
345+
346+
&lt;div id="container" style="transform:translateX(5px);">
347+
&lt;div id="bloat">&lt;/div>
348+
&lt;div id="child" style="position:fixed;">&lt;/div>
349+
&lt;/div>
350+
</pre>
351+
versus
352+
<pre>
353+
&lt;div id="container" style="position:relative; z-index:0; left:5px;">
354+
&lt;div id="bloat">&lt;/div>
355+
&lt;div id="child" style="position:absolute;">&lt;/div>
356+
&lt;/div>
357+
</pre>
358+
</div>
322359

323360
<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.
324361

css-transforms-2/Overview.bs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Module Interactions {#module-interactions}
6262

6363
The <a>3D transform functions</a> here extend the set of functions for the 'transform' property.
6464

65-
Some values of 'perspective', 'transform-style' and 'backface-visibility' 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="css2">stacking context</a>.
65+
Some values of 'perspective', 'transform-style' and 'backface-visibility' result in the creation of a [=containing block for all descendants=], and/or the creation of a <a spec="css21">stacking context</a>.
6666

6767
Three-dimensional transforms affect the visual layering of elements, and thus override the back-to-front painting order described in <a href="https://www.w3.org/TR/CSS2/zindex.html">Appendix E</a> of [[!CSS21]].
6868

@@ -625,10 +625,10 @@ All three properties accept
625625
the value <dfn value for="translate, rotate, scale">none</dfn>,
626626
which produces no transform at all.
627627
In particular,
628-
this value does <em>not</em> trigger the creation of a stacking context or containing block,
628+
this value does <em>not</em> trigger the creation of a stacking context or [=containing block for all descendants=],
629629
while all other values
630630
(including identity transforms like ''translate: 0px'')
631-
create a stacking context and containing block,
631+
create a stacking context and [=containing block for all descendants=],
632632
per usual for transforms.
633633

634634
When 'translate', 'rotate' or 'scale' are animating or transitioning, and the from value or to
@@ -666,7 +666,7 @@ Computed value: Same as specified value.
666666
Animatable: no
667667
</pre>
668668

669-
A value of "flat" for 'transform-style' establishes a stacking context, and establishes a <a>3D rendering context</a>. Elements with a used value of "auto" are ignored for the purposes of 3D rendering context computation, and those with a used value of "preserve-3d" extend the 3D rendering context to which they belong, even if values for the ''transform'' or ''perspective'' properties would otherwise cause flattening. A value of "preserve-3d" establishes a stacking context, and a containing block.
669+
A value of "flat" for 'transform-style' establishes a stacking context, and establishes a <a>3D rendering context</a>. Elements with a used value of "auto" are ignored for the purposes of 3D rendering context computation, and those with a used value of "preserve-3d" extend the 3D rendering context to which they belong, even if values for the ''transform'' or ''perspective'' properties would otherwise cause flattening. A value of "preserve-3d" establishes a stacking context, and a [=containing block for all descendants=].
670670

671671
Grouping property values {#grouping-property-values}
672672
------------------------
@@ -721,7 +721,7 @@ Where <<length>> values must be positive.
721721

722722
</dl>
723723

724-
The use of this property with any value other than ''perspective/none'' establishes a stacking context. It also establishes a containing block (somewhat similar to ''position: relative''), just like the 'transform' property does.
724+
The use of this property with any value other than ''perspective/none'' establishes a stacking context. It also establishes a [=containing block for all descendants=], just like the 'transform' property does.
725725

726726
The values of the 'perspective' and 'perspective-origin' properties are used to compute the <a>perspective matrix</a>, as described above.
727727

0 commit comments

Comments
 (0)