W3C home > Mailing lists > Public > www-style@w3.org > October 2001

Re: Re:Re: How is it possible to devise such a feeble system?

From: Håkon Wium Lie <howcome@opera.com>
Date: Thu, 25 Oct 2001 01:51:15 +0200
Message-ID: <15319.21491.310000.296168@gargle.gargle.HOWL>
To: Andrew McFarland <andrew.mcfarland@unite.net>
Cc: www-style@w3.org
Also sprach Andrew McFarland:

 > What you are wanting to do is center the text vertically in the middle of 
 > the screen (or window). I don't think CSS `knows' what size the screen (or 
 > window) is.

MOst of the CSS formatting model deals with elements (and their
associated boxes) and not the viewport (a.k.a. window). There is one
exeption, though. "Fixed positioning" lets you place elements w.r.t
the viewport. Here is a simple example on how to "center" content in
the window:

  <HTML>
  <STYLE>
  #foo {
    position: fixed;
    top: 40%;
    height: 20%;
    width: 100%;
    text-align: center;
  }
  </STYLE>
  <BODY>
  <DIV id="foo">
  bar
  </DIV>
  </BODY>

"Fixed positioning is supported by Opera and Mozilla.

It's not true centering vertically since the height DIV's content
isn't taken into the calulation. 

-h&kon
              Håkon Wium Lie                          cto °þe®ª
howcome@opera.com                  http://people.opera.com/howcome
Received on Wednesday, 24 October 2001 19:54:47 GMT

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