W3C home > Mailing lists > Public > www-style@w3.org > September 2006

Re: position / size arithmetic?

From: David Woolley <david@djwhome.demon.co.uk>
Date: Fri, 8 Sep 2006 08:38:16 +0100 (BST)
Message-Id: <200609080738.k887cGQ03156@djwhome.demon.co.uk>
To: www-style@w3.org

> > As far as I can see, though, the analoguous use of margin-vertical *does*
> > work in an absolute positioning context, which can be established by
> > relative positioning the container, with a zero offset. (CSS 2.1)
> 
> I'm not sure I follow how this is supposed to work. I tried this
> 
>       <div style="background-color: red; margin-top: auto;
> margin-bottom: auto">Trial text</div>
> 
> and it fails both in Opera 9.01 and a late-August nightly build of
> Mozilla SeaMonkey, but I'm probably reading your comment wrong.

That's because you haven't constrained top and bottom.

The following fragment works in a 2004 version of Mozilla and even
Mozilla 0.9.1 from 2001!  (Inline styles used for ease of demonstration,
not as good practice.)

<div style="position:relative; width:25em; height:25em; background-color:green">
<img div style="position:absolute; width:10em; height:10em; top:0; 
bottom:0; margin-left:auto; margin-right:auto; margin-top:auto;
margin-bottom:auto; left:0; right:0; background-color:red"
src="Summerpalace02.jpg" alt="arbitrary image for demo"> 
</div>
Received on Friday, 8 September 2006 07:38:27 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:46 GMT