Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder fireblade's Avatar
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Making layer center : how?

    hey masters! help me...

    what is the way of making a layer center to the page..? vertical and horizontal?

  • #2
    New Coder sdcomputerz's Avatar
    Join Date
    Feb 2007
    Location
    Hawaii
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just set:
    left: 50%;
    top: 50%;
    You can never have nothing, because nothing is still something.
    SD Computerz
    Free Domain Names
    Gaming Lagoon - Buying your game time!

  • #3
    Regular Coder Jutlander's Avatar
    Join Date
    Jun 2007
    Location
    In my own sick little world :P
    Posts
    425
    Thanks
    1
    Thanked 12 Times in 12 Posts
    No, use a wrapper.

    Code:
    * {
    margin: 0;
    padding: 0;
    }
    #wrapper {
    margin: 0 auto;
    width: 600px;
    border: 1px solid #000;
    padding: 20px;
    }
    Then you wrap everything inside the wrapper:

    Code:
    <div id="wrapper">
    [everything goes here]
    </div>
    .
    .

  • #4
    Regular Coder
    Join Date
    Feb 2007
    Location
    Canada
    Posts
    924
    Thanks
    10
    Thanked 56 Times in 55 Posts
    Here is a link to a page which, if I recall correctly, came from a previous posting here. Full credits to whomever posted it originally. I merely snagged a copy. Do a View Source to get the code, but essentially, centre the div using absolute positioning and then apply negative margins equal to half of the height and width. Enjoy.

    http://www.jlhaslip.trap17.com/sampl...ntereddiv.html
    Last edited by jlhaslip; 07-16-2007 at 02:56 AM. Reason: add last line

  • #5
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,486
    Thanks
    6
    Thanked 981 Times in 954 Posts
    Quote Originally Posted by Jutlander View Post
    No, use a wrapper.

    Code:
    * {
    margin: 0;
    padding: 0;
    }
    #wrapper {
    margin: 0 auto;
    width: 600px;
    border: 1px solid #000;
    padding: 20px;
    }
    Then you wrap everything inside the wrapper:

    Code:
    <div id="wrapper">
    [everything goes here]
    </div>
    Usually if somebody is speaking of a layer they mean an absolutely positioned div (since its kind of layered above the other elements) in which case this wouldnt work as well.

  • #6
    New Coder fireblade's Avatar
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanx every body who helped me to get..


  •  

    Posting Permissions

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