Web Analytics Made Easy -
StatCounter z-index not applying - CodingForum

Announcement

Collapse
No announcement yet.

z-index not applying

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • z-index not applying

    Im a little confused here, I cant get the z-index to work when it is in a class. I have a created a very simple page, no "selects", it has the position set, and the other properties in that class are being applied. Its not working in IE or in netscape. It does work when the same code is in the style instead of a class. Anyone know why this wont work?

    Code:
    <html>
    <head>
    <style>
    <!--
    .item{position:absolute; left:200; top:150; z-index:20}
    -->
    </style>
    <script language="JavaScript1.2">
    <!--
    function showzindex(){
    alert(document.getElementById("testitem").style.zIndex)
    }
    
    function showzindex2(){
    alert(document.getElementById("testitem2").style.zIndex)
    }
    //-->
    </script>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    </head>
    <body>
    <DIV id="testitem" class="item">test</DIV>
    <DIV id="testitem2" style="position:absolute; left:200; top:250; z-index:40">test2</DIV>
    <input type="button" value="Show test z-index" name="B3" onclick="showzindex()">
    <input type="button" value="Show test2 z-index" name="B3" onclick="showzindex2()">
    </body>
    </html>

  • #2
    i'm not whiz at javascript but couldn';t yopu erase all the script and do:
    Code:
    input {
    position: relative;
    z-index: ?;
    }
    if thats not what your after I do see that yournot defing the z-index:# for theinputs. your saying to get the index but not giving it aqn attribute.
    Stop making things so hard on yourself.
    i is tugbucket :: help raise tugburg :: Whitehaven Kiwanis

    Comment


    • #3
      No they are trying to get the zindex of a certain div. Javascript only reads inline styles. If you did style="z-index:20;" javascript would be able to read it.
      ||||If you are getting paid to do a job, don't ask for help on it!||||

      Comment


      • #4
        Thanks, that certainly would explain the problem. The code I posted was just an example of the problem for simplicity sake. The actual code is far more ugly. This may be tricky to work around though, I will have to be real carefull about which styles I put in the classes. Some are static, some are dynamic but dont get read via javascript, and some are dyanmic and do need to be checked via javascript.

        I see now that I can access those values via document.styleSheets but I wont ever know wether to check the stylesheet or the inline style on any object.

        Comment


        • #5
          Originally posted by nimexx
          The actual code is far more ugly.
          The frontpage generator tag gives it away
          -Jamie

          Comment

          Working...
          X