- From: Håkon Wium Lie <howcome@opera.com>
- Date: Thu, 25 Oct 2001 01:51:15 +0200
- 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 UTC