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 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How do I center layers within the browswer window?

    I found an extension in the Macromedia Exchange. I almost works perfect. The layer does not center until the page loads. It does this each time you go to a new page. Kind of hoaky. I don't think that the client is going to care for it. Thanks!!!!

  • #2
    Senior Coder chilipie's Avatar
    Join Date
    Jul 2004
    Location
    Shrewsbury, UK Age: 16
    Posts
    1,117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Using my super-human ability to mind read, I have just downloaded your code, and am debugging it. I will then burn it on to a CD and send it to your home address, which I will find by telepathy.

  • #3
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    Quote Originally Posted by brownbag
    I found an extension in the Macromedia Exchange. I almost works perfect. The layer does not center until the page loads. It does this each time you go to a new page. Kind of hoaky. I don't think that the client is going to care for it. Thanks!!!!
    I don't either. Your welcome!!!

    (hahahahahahahehehehehe heh ah hah he erh ehhhh ummmmm. Eh. Sorry, I crack myself up)
    Post some code, or better yet, a link to the page.





    Quote Originally Posted by chilipie
    Using my super-human ability to mind read, I have just downloaded your code, and am debugging it. I will then burn it on to a CD and send it to your home address, which I will find by telepathy.
    Hey, you stole that one from Hemebond, man...

  • #4
    Senior Coder chilipie's Avatar
    Join Date
    Jul 2004
    Location
    Shrewsbury, UK Age: 16
    Posts
    1,117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rmedek
    Hey, you stole that one from Hemebond, man...
    C'mon, it's called recycling, dude...Get with the times man, you're like livin' in the past... Doooooooooooood...

  • #5
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Oops, new to this!


  • #6
    Senior Coder chilipie's Avatar
    Join Date
    Jul 2004
    Location
    Shrewsbury, UK Age: 16
    Posts
    1,117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Seems fine to me (FF 1.0.1, Win. XP Pro. SP2). Anyway, what's with all the crazy JS? Try searching the forums for "vertical centering", and there should be a wealth of information available...

  • #7
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    First of all, get rid of all that javascripty-centering-crazy-talk.

    Second of all, find whatever <div> is holding the website together (I only looked at it for a sec, is it #layer1? It's #layer3 in the other pages), and get rid off all that positioning applied as an inline style.

    Third, use this:
    Code:
    #layerwhatever {
     position: relative;
     top: 50%;
     margin-top: -???px;    /* replace the ??? with half the height of the div, ex: 200px high would be 100px */
     margin: 0 auto;
     }
    This places the div in the center of the screen. Then put the other divs inside of it.

    Hope this helps...

  • #8
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks!

    Thanks!

  • #9
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    Nothin' to it (but to do it)

  • #10
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rmedek
    First of all, get rid of all that javascripty-centering-crazy-talk.

    Second of all, find whatever <div> is holding the website together (I only looked at it for a sec, is it #layer1? It's #layer3 in the other pages), and get rid off all that positioning applied as an inline style.

    Third, use this:
    Code:
    #layerwhatever {
     position: relative;
     top: 50%;
     margin-top: -???px;    /* replace the ??? with half the height of the div, ex: 200px high would be 100px */
     margin: 0 auto;
     }
    This places the div in the center of the screen. Then put the other divs inside of it.

    Hope this helps...
    I tried it it works great but only one problem.
    I used Absolute positioning instead of relative like you mentioned.
    I missed it so then when i changed it to relative it just went totally to the right in dreamweaver design view. In firefox it was displaying the same way but in IE it went way to the right.
    Are you sure you have to use relative positionin please confirm
    Thank you so much
    I never knew it was so simple and have always used tables for designs that needed to be centered.
    Please confirm the above

  • #11
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    try negative values

    #layerwhatever {
    position: relative;
    top: 50%;
    margin-top: -???px; /* replace the ??? with half the height of the div, ex: 200px high would be 100px */
    margin: 0 auto;
    }

    try this with absolute divs- for instance i have a "wrapper" div around all my other divs and they are all absolutely positioned. So the wrapper ends up starting in the center of the page and continuing off the page. Solution set the wrapper div with negative margins instead of positive. Same formula as above but negative values.
    #layerwhatever {
    position: relative;
    top: 50%;
    margin-top: -???px; /* replace the ??? with half the height of the div, ex: 200px high would be -100px */
    margin: 0 auto;
    }
    Last edited by tinsol; 01-27-2007 at 01:17 PM. Reason: typo


  •  

    Posting Permissions

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