W3C home > Mailing lists > Public > www-style@w3.org > March 2009

Re: Why no compositional positioning?

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 16 Mar 2009 09:15:48 -0500
Message-ID: <dd0fbad0903160715s296a92bfu962ee913279b6385@mail.gmail.com>
To: Thomas Davie <tom.davie@gmail.com>
Cc: www-style@w3.org
On Mon, Mar 16, 2009 at 9:08 AM, Thomas Davie <tom.davie@gmail.com> wrote:
> Maybe I am indeed missing something that is in css.  I'll give a simple
> example:
>
> <div id="a">
>  <div id="b">
>    <p>This is in div b</p>
>  </div>
> </div>
>
> #a
> {
>  position: absolute;
>  left: 100px;
> }
>
> #b
> {
>  position: parentRelative;
>  left: 10px;
> }
>
> In this example I would expect b to act as if it were absolutely positioned,
> but with the bounding box of a acting as the bounding box of the page.  i.e.
> the text "this is in div b" should appear 110px from the left of the page.

Change the #b rule to position:absolute, and it does exactly what you want.

Absolute positioning uses as its reference point the nearest ancestor
that isn't position:static.  You can use position:absolute, as in your
example, or position:relative if you don't want to remove the parent
from the flow.

~TJ
Received on Monday, 16 March 2009 14:16:23 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:17 GMT