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

John-Paul Walton <jWalton@NSideas.com> wrote on 10/24/01 12:01:34 PM:
>I think the question being asked is why can't CSS be used to horizontally
>and vertically center a DIV (or any element) within another DIV.
>
>something I've been wondering about as well.

Indeed, that is the question.  Sounds like a pretty simple concept, doesn't it?


Andrew McFarland <andrew.mcfarland@unite.net> wrote on 10/24/01 11:34:02 AM:
>At 10:00 24/10/2001 -0400, Jesse McCarthy wrote:
>>Using CSS how can I center the inner DIV
>>or really the text within the inner DIV horizontally and vertically?
>
>I'm pretty certain you can't.

That's my point.  Your statement makes me wonder whether you read my first post 
in this thread, from earlier today.  If you didn't get it, look in the archive. 

>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. Setting the height to 100% is 100% of the height of the parent 
>element, not the screen (or window).

CSS doesn't "know" anything, it is instructing the user agent.  And the user 
agent knows the resolutuion of the screen and the dimensions of the viewport.  
In an HTML document the initial containing block is represented by th HTML 
element.  If no dimensions are defined by the author for HTML, the width will 
be provided by the user agent = all of the available space within the viewport 
(browser window).  In practice, browsers do the same thing with the height, not 
to mention that, despite what the CSS 2 spec says, the browsers (at least the 
ones I have available for testing: IE 5, N 6.1 / PC / Win 98) ignore any width 
and height settings for HTML and use the entire width and height of the 
viewport no matter what.  If no dimensions are provided for BODY, it's width 
will be the same as HTML, it's parent element.  So if a DIV is placed directly 
within BODY in that situation, with it's width set to 100%, it's width will be 
the same as body, which will be the same as the viewport. 

Let's establish for purposes of this discussion that we are talking about the 
rules stated in the CSS 2 spec, insofar as they are consistent, and not 
browser's behavior insofar as it fails to adhere to those rules. 

>If you can explain where you want to use the effect we may be able to 
>suggest an alternative way of getting this to work for you.

For an example of what I am talking about, refer to this document: http://www.
jmmcc.com/testing/centering1.html . 

What I want to know is, why is there not a (extremely simple) way for me to 
horizontally and vertically center the text, contained within the inner DIV, 
'whole2'? 

Received on Wednesday, 24 October 2001 13:02:28 UTC