SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: z-index css

  1. #1
    SitePoint Member
    Join Date
    Jun 2003
    Location
    liverpool
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    z-index css

    i'm using this
    div.left = parseInt(div.left)-100;
    in a script
    so change position of a div
    so why can't i use this
    div.z-index = parseInt(div.z-index)-100;
    to change it's z-index

    any help appriciated
    Phil

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That should be zIndex, because div.z-index would treat the "-" as the subtraction operator and try to subtract a variable named "index" from div.z
    ck :: bringing chris to the masses.

  3. #3
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    You should also be using [divID].style.left and [divID].style.zIndex to call the properties rather than directly calling left and z-index.

  4. #4
    SitePoint Member
    Join Date
    Jun 2003
    Location
    liverpool
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cheers to first reply - didn't think of that, but i thought you had to use z-index cos that was it's name, so zIndex is cool yes.

    And second reply i have already put the divID into a variable so i am assuming that what you said is unnecessary - but thank none the less.

  5. #5
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    You should be doing something like this:
    Code:
    var theDiv = document.getElementById("blah")
    var myLeft = theDiv.style.left;
    var myZ = theDiv.style.zIndex;
    HTML Code:
    <div id="blah"></div>

  6. #6
    SitePoint Member
    Join Date
    Jun 2003
    Location
    liverpool
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are gonna have to excuse my stupidity - i've changed it to what you said, but now it won't even change the y pos
    http://www.philspeakman.com/test/divZ.htm
    i get the theory but am not to practised in dhtml - hence me wanting to learn, if you can shed any more light i would appriciate it, Phil


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •