<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>16328</bug_id>
          
          <creation_ts>2012-03-12 19:55:17 +0000</creation_ts>
          <short_desc>Use of &quot;containing block&quot; does not match CSS2.1 definition</short_desc>
          <delta_ts>2017-01-13 17:57:06 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>CSS</product>
          <component>Transforms</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Aryeh Gregor">ayg</reporter>
          <assigned_to name="Simon Fraser">smfr</assigned_to>
          <cc>7raivis</cc>
    
    <cc>allah.taskbar</cc>
    
    <cc>ayg</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>cmarrin</cc>
    
    <cc>dino</cc>
    
    <cc>dschulze</cc>
    
    <cc>eoconnor</cc>
    
    <cc>fremycompany_pub</cc>
    
    <cc>mikemcguire.dev</cc>
    
    <cc>oriadam</cc>
    
    <cc>pascal.blessing</cc>
    
    <cc>smfr</cc>
    
    <cc>smolnikov</cc>
    
    <cc>vvavrychuk</cc>
    
    <cc>w3bugs</cc>
          
          <qa_contact>public-css-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>65375</commentid>
    <comment_count>0</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2012-03-12 19:55:17 +0000</bug_when>
    <thetext>See Mozilla bug: https://bugzilla.mozilla.org/show_bug.cgi?id=733849

The spec says:

&quot;&quot;&quot;
Elements establish and participate in 3D rendering contexts as follows:

* A 3D rendering context is established by a a transformable element whose computed value for ‘transform-style’ is ‘preserve-3d’, and which itself is not part of a 3D rendering context. Note that such an element is always a containing block. An element that establishes a 3D rendering context also participates in that context.
* An element whose computed value for ‘transform-style’ is ‘preserve-3d’, and which itself participates in a 3D rendering context, extends that 3D rendering context rather than establishing a new one.
* An element participates in a 3D rendering context if its containing block establishes or extends a 3D rendering context.
&quot;&quot;&quot;
http://dev.w3.org/csswg/css3-transforms/#transform-3d-rendering

One problem here is that a containing block is not always an element.  For instance, in the markup

  &lt;div&gt;&lt;img src=foo&gt;&lt;div&gt;More text&lt;/div&gt;&lt;/div&gt;

the img&apos;s containing block is an anonymous block box.  What does it mean for that box to establish or extend a 3D rendering context?  If the outer div has transform-style: preserve-3d, is the img part of a 3D rendering context or not?  More concretely, consider the following:

  data:text/html,&lt;!doctype html&gt;
  &lt;div style=&quot;transform-style:preserve-3d;transform:rotatex(90deg)&quot;&gt;
    &lt;img src=image style=&quot;transform:rotatex(90deg)&quot;&gt;
    &lt;div&gt;Some text&lt;/div&gt;
  &lt;/div&gt;

In Chrome 19 dev (Linux), WebKit nightly r109732 (Windows 8), and Firefox 13.0a1, the image appears, so it is part of the rendering context.  How are we supposed to spec this?


Another problem is the statement &quot;Note that such an element is always a containing block.&quot;  As Boris points out in &lt;https://bugzilla.mozilla.org/show_bug.cgi?id=733849#c4&gt;, this isn&apos;t always true.  According to &lt;http://www.w3.org/TR/CSS2/visuren.html#block-boxes&gt;, a table box isn&apos;t a block container box, for instance.  Also, per bug 16326, we want things like table rows to be transformable, but they aren&apos;t block container boxes.  Thus they can&apos;t be containing blocks.


I suggested the following wording, which doesn&apos;t use the concept of containing blocks at all:

&quot;&quot;&quot;
Elements establish and participate in 3D rendering contexts as follows:

* If a transformable element&apos;s computed value for &apos;transform-style&apos; is &apos;preserve-3d&apos;, and either its parent is not transformable or its parent&apos;s &apos;transform-style&apos; computes to &apos;flat&apos;, it establishes a new 3D rendering context and participates in that context.

* If a transformable element&apos;s parent is transformable, and its parent&apos;s &apos;transform-style&apos; computes to &apos;preserve-3d&apos;, it participates in the same 3D rendering context as its parent.

* If an element is not transformable, or its &apos;transform-style&apos; and its parent&apos;s both compute to &apos;flat&apos;, or its &apos;transform-style&apos; computes to &apos;flat&apos; and its parent is not transformable, it does not participate in any 3D rendering context.
&quot;&quot;&quot;

However, this doesn&apos;t match how browsers behave.  See the test-case in &lt;https://bugzilla.mozilla.org/show_bug.cgi?id=733849#c7&gt;.


I&apos;m not sure what to spec here.  Any ideas?  What do Gecko and WebKit actually do?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65376</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Fraser">smfr</who>
    <bug_when>2012-03-12 20:05:24 +0000</bug_when>
    <thetext>WebKit&apos;s behavior here is buggy and a side-effect of the implementation.

When I wrote that part of the spec I wasn&apos;t sure if &apos;containing block&apos; was the right term to use. I&apos;m not sure that &apos;parent&apos; is either, since for an absolutely positioned element, what matters its its containing block, not its parent.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65379</commentid>
    <comment_count>2</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2012-03-12 20:23:42 +0000</bug_when>
    <thetext>Yes, my proposed definition changes behavior for absolute positioning.  Is this a problem, or is it a marginal enough corner case that we can just ask browsers to change?  If that&apos;s the only problem with my proposed definition, it could always be changed to have an extra special case for absolute positioning.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65415</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-03-12 22:06:11 +0000</bug_when>
    <thetext>The &quot;containing block&quot; is a rectangle; it&apos;s not an element or a box.  So talking about its styles is just nonsensical.

We really do need to decide what behavior we want in the anonymous block case and in the abspos/fixedpos cases before we can figure out how to define this....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65615</commentid>
    <comment_count>4</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2012-03-15 18:41:13 +0000</bug_when>
    <thetext>I think what we want here is to define some new term and use that instead of &quot;containing block&quot;.  Like call it &quot;transform parent&quot;, and say that the transform parent of an element is the nearest transformable ancestor if the element&apos;s position is relative or static, and the nearest ancestor with non-static position if the element&apos;s position is absolute, and the nearest ancestor that either is the root element or has a transform applied if the element&apos;s position is fixed.  All uses of &quot;containing block&quot; in the spec should be reviewed to see if they deserve to be changed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65616</commentid>
    <comment_count>5</comment_count>
    <who name="Simon Fraser">smfr</who>
    <bug_when>2012-03-15 18:45:42 +0000</bug_when>
    <thetext>That sounds reasonable. I&apos;d have to think about how to define &quot;transform parent&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65617</commentid>
    <comment_count>6</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-03-15 18:52:41 +0000</bug_when>
    <thetext>The exact definition in comment 4 is not quite right (e.g. for position:absolute or position:fixed ancestors with transform not &quot;none&quot; should probably be treated as transform parents, and similar for svg:foreignObject), but the general approach makes sense, I think.  I wonder how to best keep the definition from getting out of sync with the containing block stuff for positioned elements...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76629</commentid>
    <comment_count>7</comment_count>
    <who name="Simon Fraser">smfr</who>
    <bug_when>2012-10-18 22:24:34 +0000</bug_when>
    <thetext>Need to discuss at the F2F meeting.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76636</commentid>
    <comment_count>8</comment_count>
    <who name="Edward O&apos;Connor">eoconnor</who>
    <bug_when>2012-10-18 22:48:38 +0000</bug_when>
    <thetext>*** Bug 18500 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76713</commentid>
    <comment_count>9</comment_count>
    <who name="Simon Fraser">smfr</who>
    <bug_when>2012-10-19 17:14:51 +0000</bug_when>
    <thetext>*** Bug 19637 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110064</commentid>
    <comment_count>10</comment_count>
    <who name="Binyamin">7raivis</who>
    <bug_when>2014-08-11 17:36:47 +0000</bug_when>
    <thetext>Chrome related bug &quot;rendering bug : position:fixed AND -webkit-transform&quot; https://code.google.com/p/chromium/issues/detail?id=20574</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120058</commentid>
    <comment_count>11</comment_count>
    <who name="Binyamin">7raivis</who>
    <bug_when>2015-05-04 07:27:17 +0000</bug_when>
    <thetext>Also &quot;will-change&quot; breaks because of this issue, see http://cssmojo.com/the-dark-side-of-the-will-change-property/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126470</commentid>
    <comment_count>12</comment_count>
    <who name="Mike">mikemcguire.dev</who>
    <bug_when>2016-05-20 15:27:07 +0000</bug_when>
    <thetext>+1 for updating the spec on this issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126931</commentid>
    <comment_count>13</comment_count>
    <who name="Sergey">smolnikov</who>
    <bug_when>2016-07-08 12:01:19 +0000</bug_when>
    <thetext>+1 Still need spec update as browser won&apos;t fix this issue without having spec changed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127397</commentid>
    <comment_count>14</comment_count>
    <who name="oria">oriadam</who>
    <bug_when>2016-09-15 15:17:02 +0000</bug_when>
    <thetext>This issue was raised and discussed in 2012 and forgotten, but the position property is still non-functional inside transformed elements - to this day.

position:fixed/absolute behavior needs to be consistent. Fixpos is relative to view-port in any other case; abspos is relative to first non-static parent in any other case; there&apos;s no reason for this special exception of transformed elements.

To be honest, from the user perspective this like a margin behaves as padding on elements with round-borders... it simply makes no sense.

There&apos;s not one case where a position:fixed element needs to be relative to transformed element and not view-port. If there was such a case, the right way was to set it as position:absolute and set the parent to position:relative.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127403</commentid>
    <comment_count>15</comment_count>
    <who name="">allah.taskbar</who>
    <bug_when>2016-09-16 14:22:43 +0000</bug_when>
    <thetext>+1 for updating the spec</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127434</commentid>
    <comment_count>16</comment_count>
    <who name="">vvavrychuk</who>
    <bug_when>2016-09-20 12:26:46 +0000</bug_when>
    <thetext>As far as I understand this issue applies to `background-attachment: fixed` too. It also becomes fixed to the parent transformed block and not to the viewport.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127899</commentid>
    <comment_count>17</comment_count>
    <who name="FremyCompany">fremycompany_pub</who>
    <bug_when>2016-10-21 18:07:12 +0000</bug_when>
    <thetext>Just wanted to point out that Chrome shows that implementing this fix (position:fixed not disabled by transforms) is possible and even trivial by accidentally have this happen as a result of a bug:

https://jsfiddle.net/6phnrad7/1/

Except if we have strong reasons not to revert this change, I would recommend we revert it, and allow position:fixed to work inside transformed elements.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127900</commentid>
    <comment_count>18</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2016-10-21 19:09:54 +0000</bug_when>
    <thetext>&gt; is possible and even trivial

With what exact resulting behavior?  What&apos;s the z-ordering of the result, for example?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127901</commentid>
    <comment_count>19</comment_count>
    <who name="FremyCompany">fremycompany_pub</who>
    <bug_when>2016-10-21 20:08:21 +0000</bug_when>
    <thetext>Fair point, I think I just got too excited :-)

I would need to investigate more, but the returning theme I heard is that it would be very difficult to maintain position:fixed and apply the transform nonetheless, and from what I can see this happens by accident in a browser which makes me believe this argument doesn&apos;t hold strongly. 

I&apos;ll open an issue on the csswg github when I will have had time to investigate this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127902</commentid>
    <comment_count>20</comment_count>
    <who name="Simon Fraser">smfr</who>
    <bug_when>2016-10-21 20:12:02 +0000</bug_when>
    <thetext>Clipping is also hard to get right.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127903</commentid>
    <comment_count>21</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2016-10-21 20:32:25 +0000</bug_when>
    <thetext>&gt; I heard is that it would be very difficult to maintain position:fixed and apply the transform nonetheless

Which it is.  If you try actually scrolling your testcase at https://jsfiddle.net/6phnrad7/1/ in Chrome you will note that it&apos;s not really fixed exactly, because scrolling happens on the compositor and just brings the entire transformed thing along, including the &quot;fixed&quot; piece.  Then a relayout happens and it gets repositioned to its original viewport-relative place again.

This is probably not the scrolling behavior people expect out of &quot;position: fixed&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128158</commentid>
    <comment_count>22</comment_count>
    <who name="Pascal Blessing">pascal.blessing</who>
    <bug_when>2016-11-11 14:33:48 +0000</bug_when>
    <thetext>The problem with transform and position: fixed was an issue for me for quite a long time. Luckily I was able to solve it with some kind of JS polyfill.
However, looking up the position: sticky specs I&apos;ve just stumbled across the containing block definition of CSS 3 (https://drafts.csswg.org/css-position/#def-cb) which says:

&quot;&quot;&quot;
If the element has position: fixed, the containing block is established by the viewport in the case of continuous media or the page area in the case of paged media.
&quot;&quot;&quot;

which would conflict with the previous definition and implementation of Chrome (and finally resolve https://bugs.chromium.org/p/chromium/issues/detail?id=20574)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128377</commentid>
    <comment_count>23</comment_count>
    <who name="Simon Fraser">smfr</who>
    <bug_when>2017-01-13 17:57:06 +0000</bug_when>
    <thetext>Moved to https://github.com/w3c/csswg-drafts/issues/913</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>