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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts

    Trouble Aligning Divs

    Hi all,

    I recently left tables behind as much as possibly. Larger on the advice and rants of many reputible members here. I'm currently at the first stadges of a new website and I'm having trouble align the DIV's corect. I may have miss undestood something.

    My example is here: http://bpt.madcapsule.com/

    On screens that are 800x600 the layout is ok but if you have a larger screen size or make your browser window bigger however then the grey divs that hold a picture and spec of a trainer (make sense when you see the site) travel left, breaking out of the design. I'm using...

    position: absolute; top:nnpx; left:nnpx;
    to align in and obviously its taken the left very literally, and pulls to left when window is made bigger. I wanted it to be held within its master div so that it cant break out. Did I miss something here?

    If anyone can provide any information that would be much appreciated.
    Many thanks
    Sir P!

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,627
    Thanks
    6
    Thanked 1,001 Times in 974 Posts
    Quote Originally Posted by sir pannels View Post
    Did I miss something here?
    Yes, you missed to position the all wrapping container div relative. The absolute position is relative to the next absolutely or relatively positioned parent element. So, currently left is counted from the viewport edge while if you position the parent of that absolutely positioned element relative (as this will leave it within the regular flow of elements) the absolute position is counted from the edge of that parent element, not the viewport.

  • Users who have thanked VIPStephan for this post:

    sir pannels (02-05-2008)

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    its that simple!

    Many thanks Stephen. That will prove most useful.


  •  

    Posting Permissions

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