webkit-transform overwrites z-index ordering in Chrome 13

后端 未结 5 2017
情书的邮戳
情书的邮戳 2020-11-29 02:39

Update

Sorry for failing to add the minor detail that we also layer a lot of div elements on top of each other with z-index

相关标签:
5条回答
  • 2020-11-29 03:17

    I think you need to try using -webkit-transform or webkitTransform instead of webkit-transform.

    0 讨论(0)
  • 2020-11-29 03:20
     el.style["-webkit-transition"] = "-webkit-transform 500ms linear";
     el.style["webkit-transform"] = "translate3d(30px, 30px, 0px)";
    

    Your missing the - on the second line, this could be the problem.

    0 讨论(0)
  • 2020-11-29 03:23

    Solved it myself through trial and error. Thought I'd report back if someone else stumbles upon this problem. It shall still be noted that this problem did not occur before Chrome updated itself to Chrome 13 (13.0.782.107m).

    The trick here seems to be to add a translate3d operation to the underlying <div> (sq2) element upon declaration (or atleast before animating sq1).

    Otherwise, the translate3d operation on the overlying <div> (sq1) will cause rendering to ignore the z-index and place sq1 below sq2. I'm guessing that this is because sq1 is defined before sq2 in the DOM, therefore sq2 will be rendered above it.

    So, the solution seems to be to put translate3d in the definition of the <div>:s (add it to both just to be clear):

    HTML:
    <div id="sq1" style="z-index:10; -webkit-transform: translate3d(0px, 0px, 0px);">
    <div id="sq2" style="z-index:5; -webkit-transform: translate3d(0px, 0px, 0px);">
    
    0 讨论(0)
  • 2020-11-29 03:26

    Use el.style.WebkitTransform (uppercase W).

    0 讨论(0)
  • 2020-11-29 03:32

    This should only affect any elements which are positioned as absolute or relative. In order to remedy the issue, you can apply the following css statement to every element which is positioned this way and is causing issues:

    -webkit-transform: translate3d(0,0,0);

    This will apply the transform to the element without actually doing a transformation, but affecting it's render order so it is above the element causing the issue.

    0 讨论(0)
提交回复
热议问题