Sent by Michael Landis on 10 February 2005 23:11
ptica wrote:
> is there anyway to effectively strech an element to 100% of viewport?
> and do it, as w3c thought is should be done (it means code and CSS
validates)
> (height is not permitted for table element, if i see well the specs)
If you are talking about stretching an element to 100% of the height of the
viewport, it can be done, but only under limited circumstances. The trick
is in reading how the CSS specs define percentage heights and containing
blocks.
An element with a percentage height defaults to "auto" if its containing
block doesn't have an explicitly defined height. The one element that does
not obey this rule is the root element -- percentage heights on the root
element are based upon the viewport height.[1] In an HTML document, the
root element is the html tag.
What this means is that if you want an element to relate to the height of
the window, the html tag needs to define a height of 100%, to let its
children use percentage heights. If you want to define an immediate child
of body as 100% high, then body also needs a height of 100%, so that html's
defined height gives body's height a definition, and body's height gives
its children a definition, and so on.
The specifications say that absolutely positioned elements can be defined
with percentages, without having percentages defined on their containing
blocks. IE, however, doesn't understand this. *sigh*
HTH,
Michael
[1] http://www.w3.org/TR/CSS21/visudet.html#the-height-property
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/