Processing
 

How to show a div over a Youtube video (z-index)?

10/08/2011 19:34#1

Edvard

Member

Joined at: 7 months ago

Post: 2

Thank: 0

Thanked: 0

I want to show a div over a YouTube video but can't get it to work. I know that if you set the wmode to transparent or opaque it should work, but I've only seen this work when the <embed> or <object> tag is used. YouTube now embeds the video in an <iframe> so when I tried it, it didn't work. Here's what my code looks like.

     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">     <html xmlns="http://www.w3.org/1999/xhtml">     <head>             <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />         <title></title>         <style type="text/css">@import "reset.css";</style>          <style type="text/css">             body {             background:#000;             font:62.5%/240% Helvetica, Arial, sans-serif;             overflow:hidden; /* To avoid showing a scrollbar */             }             div {             background:#f00;             position:absolute;             min-width:100%;             min-height:100px;             z-index:99;              }         </style>     </head>     <body>         <div></div>         <iframe width="100%" height="100%" src="http://www.youtube.com/v/8lVJV--SrGg&loop=1&autoplay=1&autohide=1&hd=1&modestbranding=1" frameborder="0"  allowfullscreen></iframe>     </body>     </html> 
16/01/2013 21:41Top#2

Joined at: 7 months ago

Post: 1

Thank: 0

Thanked: 0

I added the ?wmode=opaque at the end of the embed "link" and it worked for me.

http://www.youtube.com/embed/I7a3acpVp1g?wmode=opaque worked for me. so in full it is

 <iframe width="250" height="188" src="http://www.youtube.com/embed/I7a3acpVp1g?wmode=opaque" frameborder="0" allowfullscreen></iframe> 
10/08/2011 19:44Top#3

Joined at: 10 months ago

Post: 10

Thank: 0

Thanked: 0

Apparently when using an iframe it sets the wmode automatically to windowed so try setting the flash player's wmode directly by modifying the iframe src like so:

src="http://www.youtube.com/v/8lVJV--SrGg?loop=1&autoplay=1&autohide=1&hd=1&modestbranding=1&wmode=opaque"

As you can see I added &wmode=opaque to the end of the parameter list. That should enable you to now overlay a div. Parameters also start with a ?, not a &.

31/12/2014 22:22Top#4

mary

Member

Joined at: 10 months ago

Post: 11

Thank: 0

Thanked: 0

After rel=0 (I already had this) I added this &modestbranding=1&wmode=opaque" and now this work properly for all major browsers, included IE11.0. So, this is worked for me. Thanks a lot and Happy New Year 2015! to all members of this community.

16/02/2016 01:47Top#5

Joined at: 7 months ago

Post: 1

Thank: 0

Thanked: 0

Try this code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">     <html xmlns="http://www.w3.org/1999/xhtml">     <head>             <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />         <title></title>         <style type="text/css">@import "reset.css";</style>          <style type="text/css">             body {             background:#000;             font:62.5%/240% Helvetica, Arial, sans-serif;             overflow:hidden; /* To avoid showing a scrollbar */             }             div {             background:#f00;             position:absolute;             min-width:100%;             min-height:100px;             z-index:99;              }             iframe {             position:absolute;             min-width:100%;             min-height:100%;             }         </style>     </head>     <body>         <div></div>         <iframe src="http://www.youtube.com/v/8lVJV--SrGg?loop=1" frameborder="0"></iframe>     </body>     </html> 
Similar articles

Open a folder in finder/explorer from a webpage?

5 years ago - Reply: 2 - Views: 80

How do I escape a reserved word in Actionscript?

5 years ago - Reply: 2 - Views: 198

Save PPS/PPT files as SWF using C#

5 years ago - Reply: 2 - Views: 171

Ways of making a graphic/visual novel in flash

6 years ago - Reply: 3 - Views: 114

Use PhoneGap + HTML5 and an Embedded Flash Movie

5 years ago - Reply: 2 - Views: 96

View word docs and PDF in browser?

5 years ago - Reply: 2 - Views: 52

ActionScript 3 Read JPEG quality

7 years ago - Reply: 2 - Views: 59

Export/Test Movie Issues

5 years ago - Reply: 3 - Views: 38

Flash always on top in Android browser workaround?

5 years ago - Reply: 2 - Views: 149

Sending Json Form from Flash AS3

5 years ago - Reply: 2 - Views: 29

parsing a swf/fla (using php?)

6 years ago - Reply: 2 - Views: 44

Getting high FPS on Flash/AIR games for mobile?

4 years ago - Reply: 2 - Views: 58

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re