iPad Safari mobile seems to ignore z-indexing position for html5 video elements

前端 未结 11 2024
鱼传尺愫
鱼传尺愫 2020-11-29 04:46

I got a video element on a page that\'s working fine both in safari mobile and desktop. I have a seme-transparent pull-down menu that\'s working fine. The problem is, when t

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 05:02

    I'm using flowplayer and a simple CSS dropdown menu and had the same problem.

    I have drop down menu that, when tapped, covers part of the video area. The submenu shows up over the video as expected, but no touch events were being sent.

    I fixed it by combining a couple of suggestions from others answering this question: I set visibility:hidden when opening the menu and visibility:visible when closing the submenu, AND set the -webkit-transform-style:preserve-3d CSS property on the video.

    Here's the pertinent code. I left out the CSS for the menubar, but it does what you might expect - resulting in a menu that covers portions of the video.

    menu and video HTML

    
    

    CSS

    video {
      -webkit-transform-style: preserve-3d;
    }
    

    Javascript

    $(document).ready(function(){
      $("#nav li").hover(
        function() {
          $(this).find('ul:first').css({visibility: "visible",display: "none"}).fadeIn(300);
          $("video").css({visibility:"hidden"});
        },
        function(){ 
          $(this).find('ul:first').css({visibility: "hidden"});
          $("video").css({visibility:"visible"});
        }
      );
    );
    

提交回复
热议问题