Re: position / size arithmetic?

On 9/3/06, David Woolley <david@djwhome.demon.co.uk> wrote:
> I'm not sure why you went off list.  I have no objection to this being
> copied on list.

Sorry, my fault, forgot to reply to all :P

> > > > 50px high, and I want it exactly centered horizontally.  I would like to
> > >
> > > margin-left:auto; margin-right:auto
> >
> > Which however, IIRC, doesn't work for /vertical/ centering.
>
> But the question said /horizontal/

True :) I was just extending the matter a bit while trying to remain on-topic :)

> The vertical centering question has also been asked a lot.  The main
> problem with vertical centering is that it tends to require a look ahead
> in order to determine one or both heights, or whether there are other
> block level items after the subject.

Just as table layout does, which is why one often sees tables abused
for this kind of stuff (too).

> 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

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
  <body>
    <div style="height: 250px ; background-color: blue; position:
relative; left: 0px">
      <div style="background-color: red; margin-top: auto;
margin-bottom: auto">Trial text</div>
    </div>
  </body>
</html>

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.

-- 
Giuseppe "Oblomov" Bilotta

Received on Monday, 4 September 2006 12:42:42 UTC