Previous Message
Next Message

Re: [css-d] Dumb simple centering question

Sent by Andrew Clover on 28 February 2002 18:06


Tim Glen [EMAIL-REMOVED]> wrote:

> Just to let you know, however, it doesn't work in IE5 Mac. Vertically
> speaking, the image is half off the top of the page.

Mm. Different browsers do different things with top/bottom margins,
especially negative ones. This can be avoided using positioning instead:

  body { margin: 0; padding: 0; height: 100%; }
  div.center {
    position: absolute;
    left: -HalfXpx; top: -HalfYpx;
    width: 100%; height: 100%;
  }
  div.center div {
    position: absolute;
    left: 50%; top: 50%;
  }

  <div class="center"><div>
    <img ... />
  </div></div>

(You can position the image instead of using a second nested div if
you don't care about Netscape 4.)

-- 
Andrew Clover
[EMAIL-REMOVED]
http://and.doxdesk.com/
Previous Message
Next Message

Message thread:

Possibly related: