[HTML] : centered layers

Discussion in 'Web Design & Coding' started by NerdUprising, Jul 20, 2004.

  1. NerdUprising

    NerdUprising [ Method ]

    Messages:
    736
    Location:
    Kamarupta
    I'm writing a page in which there are two layers over top of one another (a swf in one, an image behind it in another). I would like to have the layers be centered in any resolution, rather than just writing it for basic 1024x768, but with my not-so-great knowledge of HTML, I dont know how to go about it. I searched through HTML forums/tutorial sites, and couldn't find anything, possibly because I'm blind.

    Any pointing in the right direction/suggestions/directions would be greatly appreciated, thanks.
     
  2. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    you want to create a css definition that contains:

    margin-left: auto
    margin-right: auto

    and apply it to the layers you want centred
     
    NerdUprising likes this.
  3. Khayman

    Khayman I'm sorry Hal... Political User Folding Team

    Messages:
    5,518
    Location:
    England
    you can cheat and do it the old fasioned, non standards way with <center>stuff</center>
     
    NerdUprising likes this.
  4. NerdUprising

    NerdUprising [ Method ]

    Messages:
    736
    Location:
    Kamarupta
    I played with an insane amount of things to try and get this to work, and I finally reached a point of success with "style="margin-left: auto; margin-right: auto;" in the layer's tag. This, for one reason or another, wouldn't work with two or more layers... they would be centered, but wouldn't be over top of one another anymore. No big deal, I just made the shadow part of the swf, and placed it in one centered layer - less chance of there being a code mishap when the page is rendered that way anyway.

    Thank you for the help, sirs.
     
  5. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    keep the margin-left and margin-right for each of them they will keep it centered if you set a width for each section as well
    to make the layers overlay you will need to set the z-index. put a z-index of 0 for the bottom layer and a z-index of 1 or greater for the top layer, that should work
     
  6. NerdUprising

    NerdUprising [ Method ]

    Messages:
    736
    Location:
    Kamarupta
    yeah, it was odd like that - I had the z-index' set for each (0 and 1), and the layering had worked before I put the margin-left/right in the tag. After the change, the two layers would show up in the page one after the other, the second layer using the "margin-top=" or "top:" pixel number as the space between the first layer and the second, rather than from the top of the page. Odd, yes?