Right Aligned Nested Div Goes Off

Discussion in 'HTML' started by vunet, Jan 8, 2008.

  1. vunet

    vunet Guest

    Hello,
    I have a div inside of the div:

    <div id='container' style='position:relative;width:500px;'>
    <div id='right' style='position:absolute;width:50%;right:
    0px;'>right</div>
    container
    </div>

    with that CSS above, 'right' div is aligned to right of the page, not
    container, even though it is nested. It gets fixed when I set
    container to have position:absolute. What CSS properties should I be
    looking at in this case?
    Note: example above is not the test-case but just an explanation.
    'container' is nested within other HTML tags in real code.

    Thank you for ideas.
    vunet, Jan 8, 2008
    #1
    1. Advertising

  2. vunet

    Jeff Guest

    vunet wrote:
    > Hello,
    > I have a div inside of the div:
    >
    > <div id='container' style='position:relative;width:500px;'>
    > <div id='right' style='position:absolute;width:50%;right:
    > 0px;'>right</div>
    > container
    > </div>
    >
    > with that CSS above, 'right' div is aligned to right of the page, not
    > container, even though it is nested.



    Absolute is always absolute to the page. Relative is to it's normal
    place in the document flow. You probably want to look at float: right,
    and then you may wish to float your other div.

    Jeff



    It gets fixed when I set
    > container to have position:absolute. What CSS properties should I be
    > looking at in this case?
    > Note: example above is not the test-case but just an explanation.
    > 'container' is nested within other HTML tags in real code.
    >
    > Thank you for ideas.
    Jeff, Jan 8, 2008
    #2
    1. Advertising

  3. vunet

    Bergamot Guest

    vunet wrote:
    >
    > 'right' div is aligned to right of the page, not
    > container, even though it is nested. It gets fixed when I set
    > container to have position:absolute.


    Your code snippet is not telling the whole story. Post a URL.

    --
    Berg
    Bergamot, Jan 8, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nick Howes

    right-aligned img in a div

    Nick Howes, Oct 13, 2003, in forum: HTML
    Replies:
    6
    Views:
    443
    David Dorward
    Oct 16, 2003
  2. mre
    Replies:
    2
    Views:
    429
  3. =?Utf-8?B?QmlzaG95?=
    Replies:
    0
    Views:
    963
    =?Utf-8?B?QmlzaG95?=
    Dec 28, 2006
  4. Ian
    Replies:
    6
    Views:
    971
    Andrew Morton
    Jan 7, 2010
  5. RICHARD BROMBERG

    ASP CDONTS goes off screen

    RICHARD BROMBERG, Feb 12, 2005, in forum: ASP General
    Replies:
    3
    Views:
    148
    RICHARD BROMBERG
    Feb 12, 2005
Loading...

Share This Page