YouTube video content covering CSS drop down menus in IE < 9

我的梦境 提交于 2020-01-13 08:31:30

问题


I've created drop down menus using CSS and I have a YouTube video placed in a box just below my nav bar. When using IE 8, the drop down menus fall behind the YouTube video, despite the fact that the div with the nav bar has a higher z-index than the div with the YouTube video. The problem does not exist in Firefox, Safari or IE9.

You can see the problem by going to the web site:

http://www.mensdiscipleshipnetwork.com

Thanks for the help.


回答1:


It looks like you need to add ?wmode=transparent to the YouTube embed iframe src url. Like so:

<iframe width="632" height="390" src="http://www.youtube.com/embed/_K-YwgCyg70?wmode=transparent" frameborder="0" allowfullscreen></iframe>



回答2:


You can add that parameter automatically to all iframes src like so:

$(document).ready(function()
    {
        $('iframe').each(function()
        {
               var url = $(this).attr("src");
                var char = "?";
              if(url.indexOf("?") != -1)
                      var char = "&";

                $(this).attr("src",url+char+"wmode=transparent");
        });
    });



回答3:


If you are using embed, wmode needs to be an attribute rather than part of the URL wmode="transparent"




回答4:


If you're using the iframe API you can add it like this (note the last param in the playerVars object):

player = new YT.Player(playerID,
        {
            width: '100%',
            height: '100%',
            videoId: vidID,
            playerVars: {
                controls: 2,
                autohide: 1,
                showinfo: 0,
                modestbranding: 1,
                wmode: 'transparent'
            }
        });


来源:https://stackoverflow.com/questions/7747133/youtube-video-content-covering-css-drop-down-menus-in-ie-9

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!