IE z-index bug affecting Youtube videos

I've been experimenting with the YouTube API and I've included the following code snippet in http://jsfiddle.net/aaronk85/wapFR/.

<div id="video-wrap2"></div>
<div id="video-wrap">
    <div id="play-video"></div>
</div>
<style>
#video-wrap2 {
    background-color: red;
    width: 666px;
    height: 666px;
    z-index: 1000;
    position: absolute;
}

#play-video {
    display: inline;
    float: left;
    height: 400px;
    width: 100%;
}

#video-wrap {
    float: left;
    display: inline;
    width: 610px;
    overflow: hidden;
    position: absolute;    
    z-index: 1;
}
</style>
<script>
$(document).ready(function() {
    $("#embed").replaceWith("<div id ='play-video'></div>");
    $.getJSON("https://gdata.youtube.com/feeds/api/playlists/UUJUAqHnkDX15IvFoXIGTm2A?alt=json-in-script&callback=?&max-results=1", function(data) {
        $.each(data.feed.entry, function(i, item) {
            var dataContainer = $("#play-video");
            var video = item.media$group.media$content[0].url;
            video = video.replace('https://www.youtube.com/v/','https://www.youtube.com/embed/');
            video = video.replace('version=3&f=playlists&app=youtube_gdata','wmode=opaque');
          $('#play-video').append("<iframe wmode='opaque' style='z-index:0;position:absolute;' width='610' height='400' src="+video+"' frameborder='0' name='vid-frame' id='vid-fade' allowfullscreen></iframe>");    
        });
    });
});
</script>

I'm trying to make video-wrap 2 appear on top of the video (random playlist I've selected). Everything seems to be working fine in all browsers except for IE. What am I missing in IE?

I've experimented with combinations of opaque/transparent but can't seem to get it right. Despite finding similar questions online and trying their solutions, I'm still facing difficulties.

Answer №1

Unique Demo

In the Internet Explorer web browser, the stack order for the z-index property may be reset for child elements based on the webpage layout.

In your specific case, you are also utilizing the position:absolute for all elements except the child element.

To remedy this issue, make sure to include position: absolute; in your CSS styles for the #play-video element.


This alternative Demo omits the use of z-index property and solely relies on setting position:absolute for the child element #play-video.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using a jQuery UI accordion with a numbered list

As part of my company's user documentation, I am trying to integrate jQuery UI components into our HTML output. Despite my limited experience with JavaScript, I was able to get the accordion feature working for table rows. However, I am now facing dif ...

Title vanishes when gradient is added to a div

I have encountered an issue with a recent update on my webpage. Previously, I had multiple divs with the title attribute that displayed information when users hovered over them. However, after adding a gradient background, the titles stopped appearing. Th ...

Tips for aligning text to the left instead of the right when it exceeds container width in IE 11

Within the div, there is text with a 5px margin on the right. When the container div narrows, the text overflows from the container and loses the right margin. Is it feasible to maintain this margin on the right side while allowing the text to overflow fro ...

What is the process for setting an AMP-video as a full-page background?

My homepage features a captivating hero video in the background, but I've encountered an issue where the AMP video does not scale properly to fit the screen on mobile devices. Here's the code snippet causing the problem: <amp-v ...

Saving data returned by PHP in an AJAX call

I am currently working on storing data from an ajax (jquery) response into a variable so that I can utilize it later in my code. Below is the jQuery code snippet: $(document).ready(function () { $("#submitReg").click(function () { var email = $(" ...

Variations in ajax requests coupled with a polling mechanism

Suppose the initial ajax call is made right away, and the function called by the controller keeps looping until it reads something, as shown below: def FirstAjax(): while True: if something is read: val = something brea ...

What are the steps to convert this code into Angular syntax?

After realizing that using jQuery alongside Angular is not a good practice, I am determined to modify my code in this Angular App to eliminate the need for jQuery. Currently, I have a page that displays menu items fetched from the server and I loop throug ...

Chrome Table not behaving as expected when expanding div

I'm encountering an issue on my website where everything works perfectly in Firefox, IE, and Safari, but there is a glitch in Chrome. You can see the problem here: http://tinyurl.com/chxg2tb In Chrome, the table at the bottom extends beyond the cont ...

Unable to establish session using jquery

I am trying to set a session using jQuery, but I keep encountering this error. I have looked for solutions online, but haven't been able to find one that works. Can someone please help me out? Thank you! ...

The check is ineffective: if (isset ($_PHP["form_name"]))

I believe there is an issue with the form validation in the file. It seems that all forms with queries are being executed without proper checks. The code snippet below shows my attempt to address this using if (isset($_POST ['form_name'])), but i ...

Leveraging jQuery to access data attributes in JSON data using AJAX requests

I am having success with a simple ajax call that returns JSON data. However, I am facing difficulties selecting elements with jQuery after the ajax call. Could this be because of how they are loaded? Currently, I am attempting to alert the contents of one ...

Do not reload the page after a successful ajax request

I'm using an Ajax section to submit data in Laravel. I want the page to not reload if the submission is successful, but to reload if there's an error. Currently, when there is an error, the page reloads correctly. However, I'm facing an issu ...

What are the steps to designing an overlay using CSS?

Looking to generate a div with a custom size and then place something on top of it. How can I accurately position and resize the overlay to match the underlying div using CSS? ...

Utilizing the Ajax success callback to trigger a subsequent Ajax request as the loop iterates

I am currently working on a piece of javascript/jquery code that involves making ajax requests. The code snippet I have includes various variables and functions for handling external data sources and templates. var trigger = $('#loadTabl ...

The realm of jQuery entities and attributes

let firstElement = document.body.children[0]; $('li', firstElement); // creating a selection within another selection let paragraphSelection = $('p'); $('a', paragraphSelection); This code snippet is taken from a tutorial fo ...

The image loads successfully from an AJAX request in CodePen, but fails to load in the local

I am currently working on integrating a weather API into my basic website and I would like to incorporate the weather icons as well. The API request successfully works in both my local and live environments, however, I encounter an error with the icon spec ...

Having difficulty accessing POST data through $.ajax request

I am currently working on a simple JavaScript code that is set up to send POST requests to my local server. The JavaScript and PHP files are both located on localhost, so I don't have to worry about any cross-site issues for now. Here is the JavaScrip ...

ASP.NET DIV is experiencing issues with Jquery functionality, causing it to flicker and remain fixed in place

As a beginner in JQuery, I am facing an issue with my code in asp.net. Whenever I click on linkbuttons, the behavior is not as expected. The div flickers and does not change its direction. My goal is to move the DIV left or right by 200px, but no matter wh ...

Place the menu on top of the div by adjusting the z-index

Hey there, I'm working on a project and I need help with an issue. You can check out the example page here: If you try to open the menu and click between "list" and "new ads", you'll notice that you're actually clicking on the dropdown se ...

Arranging columns with Bootstrap

I have a unique design using Bootstrap as shown below: <div class="row"> <div class="col-md-2"> 1 </div> <div class="col-md-8"> 2 </div> <div class="col-md-2"> 3 </div> </d ...