IE z-index anomaly

My line of floated divs reveals a popup when hovered over, but the popup appears under the following divs instead of on top. I've tried using z-index with no success to fix this issue.

UPDATE: The problem has been resolved with some assistance, but it still persists in IE7 and older versions.

Does anyone have any suggestions on how to solve this?

HTML

<div>

    <div>
        <img src="/bc.jpg" width="54" height="54" id="bc-icon" alt="test1" />
        <span><strong>test1</strong><br />dfgsertsrytwsertyrtyrsty</span>
    </div>

    <div>
        <img src="/bb.jpg" width="54" height="54" id="bb-icon" alt="test2" />
        <span><strong>test2</strong><br />dsfgsdfgsdfgsdfgsdfgsdfgsdfg</span>
    </div>

    <div>
        <img src="/rd.jpg" width="54" height="54" id="rd-icon" alt="test3" />
        <span><strong>test3</strong><br />dfgdfgdsfgsdfgsdfgsdfgsdfgsdfg</span>
    </div>

    <div>
        <img src="/bl.jpg" width="54" height="54" id="bl-icon" alt="test4" />
        <span><strong>test4</strong><br />dsfgsdfgsdfgsdfgsdfgsdfg</span>
    </div>

</div>

CSS

div {clear:both; padding:0 0 8px 0; border:none; width:576px;}

div div { float:left; margin: 0 8px 0 0; padding:0; width:56px; clear:none; overflow:visible; position:relative; background-color:#B22222;}       

div div img { padding:1px; cursor:pointer; display:block;}

div div span { background-color:#89A7BA; position:absolute; bottom:26px; left:-19px; padding:5px 10px; font-family:'MS Sans Serif',Geneva,sans-serif;  border:2px solid #FFF; font-size:12px; display:none;}

div div span img { position:absolute; bottom:-18px; left:34px;}
div div span strong {font-size:14px; text-transform:uppercase;}

JQuery is used to create the popups...

$.fn.hoverAnimation = function() {
    return $(this).each(function() {
        return $(this).hover(function() {
            $(this).find("span").slideDown(100);
            $(this).css("background-color", "#000");
        }, function() {
            $(this).find("span").slideUp(100);
            $(this).css("background-color", "#B22222");
        });
    });
}

$("div > div").hoverAnimation();

Check out my updated jsfiddle here

Answer №1

It seems that IE7 is causing some trouble with running this correctly. The issue lies in how IE7 calculates z-indexes based on the z-index values of parent elements, which must be explicitly set. Whenever you utilize position, it impacts the z-index. This creates a bit of a dilemma for you. Typically, setting the parent element to position:relative; z-index:1 would reset the z-indexing, but in your scenario, this approach won't suffice because you need to apply it to both the initial div and all child divs (which also have position: relative). Setting it on the child divs initiates a new z-index stack, leading to the same problem.

However, there may be a workaround. Consider only applying position: relative to the child divs when jQuery is triggered. Take a look at this example

Answer №2

Here is the resolution to the issue at hand, any number greater than the current one should suffice

span {z-index:200}

Live demo can be found here

http://jsfiddle.net/dfgsH/

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

Guide to modifying CSS properties of an individual element by manipulating class names with JavaScript

I have been searching for an answer to my question without success. I have a unique challenge where I need to change the styles of an h1 element by adding a class based on which radio button is clicked. The issue I'm facing is that when I select a dif ...

The hyperlink is not functioning properly because of the CSS code

I found a helpful menu on this site http://www.jqueryscript.net/menu/interactive-menu-css3-jquery.html However, I encountered an issue. When I click on <a href="1.html">Application 1</a> It doesn't redirect to 1.html as expected. The p ...

Prepare JSON data for Flot charts

I need to format JSON data from PHP post using Flowcharts in the following format: [2, 16, 0, 12, 22, 5, -10, 5, 15, 2, 11, 55] To render the charts, I use the following javascript command: _initSparklineChart($('#kt_chart_sales_by_apps_1_2') ...

Implementing CSS styling within a JavaScript file

I have a vague memory of an easy way to incorporate CSS code within a JS file, but I can't recall the specific details. Simply inserting CSS code into a JS file doesn't seem to work, so there may be a need for comments or some other method. *No ...

Looking for a jQuery Gantt Chart that includes a Treeview, Zoom functionality, and editing capabilities?

I am in need of integrating a dynamic Gantt Chart tool into a room booking solution using jQuery. The Gantt chart should be highly interactive, allowing for drag-and-drop functionality, a tree view on the left to group tasks, and a zoom feature for adjusti ...

Limit the bootstrap datepicker to display only certain dates and today's date

I've integrated the Bootstrap Datepicker into my website. I need to customize it so that only specific dates are enabled, including today's date, and all other years, months, and days are hidden from the Datepicker. How can I achieve this? Furth ...

Having difficulty changing placeholder text style in Scss

I'm a newcomer to SCSS and I'm attempting to customize the color of my placeholder text from light gray to dark gray. Below is the HTML code snippet: <div class="form-group"> <textarea class="thread-textarea" ng-maxlength="255" ma ...

Show a concealed dropdown menu within a CSS grid column utilizing clip-path styling

Working on a Django admin header that makes use of CSS grid to create two columns. I have added a JavaScript dropdown effect to the user icon for displaying options like "Change Password" and "Log Out". However, encountering an issue where the dropdown rem ...

What is the optimal order for executing JavaScript, jQuery, CSS, and other controls to render an HTML page efficiently?

What are some recommended strategies for optimizing webpage loading speed? What key factors should be taken into consideration? ...

CSS: Concealing a separate div

I am working with a parent div in my code that has 2 child divs. I am hoping to find a way to hide the second child when hovering over the first child, using only CSS or JavaScript. Take a look at my Fiddle here <div class="parrent"> <div id ...

Adjust the appearance of self and other classes on hover using CSS

I'm looking for a way to use the :hover effect in CSS to change the font color of one class (.footer_status_tex) and the background color of another class (.footer_status_gear). Here's a simplified version of what I have in mind: CSS .footer_s ...

Observing data retrieved via ajax in Internet Explorer 9

Is there a way to view data returned by an ajax script in Internet Explorer 9? For instance, Firefox has the Firebug 'All' tab with a 'Response' Sub Tab that displays data returned by an Ajax Script. How can this be done in Internet Ex ...

Ways to update div content following a successful AJAX call

I have a form that utilizes AJAX requests, and when the input fields are not filled correctly and the submit button is clicked, error messages are displayed without refreshing the page. While this functionality works, a problem arises when the form is subm ...

The button similar to Facebook does not function properly when using fancybox

My photo gallery uses fancybox, and when fancybox is open a like button appears outside the title. However, the Facebook like button doesn't seem to work. Here is my JavaScript code: $(".fancyboxi").fancybox({ padding: 0, openE ...

Discover the secret to halting a CSS animation precisely on the final nth-child in CSS3

I have encountered some difficulty in stopping a crossfade animation on the last nth-child element. Although I am aware of using animation-fill-mode: forwards, implementing it in different places such as in the initial .crossfade declaration did not yield ...

CSS changes triggered by JQuery are ineffective

Having trouble modifying the CSS of a class in my HTML file. I've been struggling with this for quite some time and can't figure out what I'm doing wrong. (I've already attempted multiple versions, but nothing seems to work) Here' ...

The jquery ajax call only seems to function properly when executed on a local

Currently, I am utilizing jQuery ajax to retrieve data from a back-end method in asp.net using the following code: $.ajax({ cache: false, type: "POST", url: '<%= Page.ResolveUrl("~/Live/Live.aspx/GetViews") %>', content: "j ...

In React Native, changing the translation of an element causes it to shift below all other elements, regardless of

Check out this sandbox project: I'm trying to create a simple animation using translation in React Native, but I'm facing an issue where when I move the element to the right and down, it goes under other elements. However, if I move it left and ...

Extracting a subclass from an array

Currently, I am delving into the world of coding as part of a project I'm working on. Here is an excerpt from my JavaScript code that interacts with Google Maps API: for (i = 0; i < results.length; i++) { console.log("Formatted Address: "+ re ...

Using Jquery to update links based on the cookie value, then replacing the original link with the new one after it has

I have a unique cookie value: snackAttack Here are some links with the same class "t": <a href="link1.html" class="t">link1</a> <a href="link2.html" class="t">link2</a> <a href="link2.html" class="t"><img src="image2.jpg ...