Bug in CSS3 rotateY transition on Safari?

后端 未结 3 763
南方客
南方客 2020-12-01 17:06

I am showing a modal popup using CSS3 transitions (largely borrowed from Effeckt.css). It works well in all modern browsers except Safari. In Safari, the movement is OK, but

相关标签:
3条回答
  • 2020-12-01 17:17

    I found this issue when trying to find a solution to a problem I was experiencing in Safari (Mac and iOS), where a y-rotated svg only displayed its right half for no apparent reason.

    In my case, the svg was a child of a fixed-position div, and I found that both position: fixed and position: absolute on the parent caused half the svg to disappear.

    Neither changing z indexes, perspective, nor translate-z seemed to solve the issue. But randomly, adding a new div around my svg and setting its background-color solved the problem. I hope this helps the next person :)

    0 讨论(0)
  • 2020-12-01 17:30

    As far as I can tell it's a bug, yes, Safari is rendering intersection where it shouldn't.

    For some time I thought Safari is doing it right by always rendering intersection of elements, but as far as I understand the specs, only elements in the same 3d rendering context should intersect, and that would be children of elements with a transform-style of preserve-3d.

    So far the only workaround I found (only tested on Windows yet where Safari shows the same behaviour) is to translate the underlying elements away on the z-axis. Without perspective being applied it won't actually translate, but Safari/Webkit seems to think it does (which probably is because it mistakenly treats the element as if it were in the same 3d rendering context as the actually transformed dialog) and so the elements do no longer intersect.

    .effeckt-overlay {
        position: fixed;
        width: 100%;
        height: 100%;
        visibility: hidden;
        top: 0;
        left: 0;
        opacity: 0;
        -webkit-transition: 500ms;
        -o-transition: 500ms;
        transition: 500ms;
        z-index: 1000;
        background: rgba(0, 0, 0, 0.5);
    
        -webkit-transform: translateZ(-1000px);
    }
    

    http://jsfiddle.net/eJsZx/5/

    0 讨论(0)
  • 2020-12-01 17:35

    In my case, adding z-index: 0 to the parent element fixed it as per Thomas's suggestion.

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