Bug Tracker

Opened 12 years ago

Closed 12 years ago

#9667 closed bug (wontfix)

jQuery .css can't read z-index value on Webkit browsers

Reported by: RAMilewski Owned by:
Priority: low Milestone: 1.next
Component: css Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:


jQuery("#X").css("z-index"); always returns "auto" on Webkit browsers. Works ok on Firefox.

It also appears that you can't set the z-index with something like: jQuery("#X").css("z-index",5);

Test case follows:

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <title>jQuery CSS Z-index Fail</title>
    <script src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
    <script type="text/javascript">
    <style type="text/css">
      h1 {z-index: 3;}
     <h1 id="X">Some Text</h1>
     <div id="Y"> Z-index is: </div>

A more complex test case can be found at http://netfools.com/anaglyph/

Change History (2)

comment:1 Changed 12 years ago by RAMilewski

This bug should be marked invalid.

This is not a jQuery problem. Webkit browsers will not return the z-index value specified in style sheets unless the element is also positioned.

h1: {

position: relative; z-index: 3;


fixes the problem

comment:2 Changed 12 years ago by timmywil

Component: unfiledcss
Priority: undecidedlow
Resolution: wontfix
Status: newclosed

I understand it being confusing that the computed z-index is auto when you've specifically set one with .css, but RAMilewski makes a good point that computed z-index will be different in different browsers. We could lie (in a sense) and say that what was set is being applied so that return values are consistent, or users can realize that the z-index will not be applied without setting the other styles to make z-index work. I'm closing wontfix as I suspect this will not be something we will change, but if anyone disagrees, we can reopen in the future.

Note: See TracTickets for help on using tickets.