Version: 4.0 (using KDE 3.1.0) Installed from: SuSE Compiler: gcc version 3.2 OS: Linux (i686) release 2.4.19-4GB In the following example, the navbar does not get 100% of the viewport, the height is just enough to hold the contents. http://dhtmlkitchen.com/experiment/safari/css/height2.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>height: 100%</title> <style type="text/css" media="screen"> html, body{ height: 100%; margin: 0; padding: 0; } #nav{ height: 100%; background: moccasin; width: 100px; position: relative; color: brown; } #contents{ position: absolute; left: 150px; left: 130px; top: 10px; margin: 20px; } </style> </head> <body> <div id="nav"> #nav{ height: 100%; background: moccasin; width: 100px; <b>position: relative;</b> color: brown; } </div> <div id="contents"> <h1>Testing height: 100%</h1> <h2>Relative Demo</h2> <p> The nav should fill the viewport, and it does in safari. (<a href="height2.gif">pic</a>) </p> </div> </body> </html>
Created attachment 1748 [details] The pasted example as file for earsier access... The bug still appears in khtml-2003-06-03.
Subject: kdelibs/khtml CVS commit by zrusin: correctly compue the height for relatively positioned objects with percentage based dimensions - pretty much a merge from safari CCMAIL: 53902-done@bugs.kde.org M +5 -0 ChangeLog 1.93 M +22 -5 rendering/render_box.cpp 1.221 --- kdelibs/khtml/rendering/render_box.cpp #1.220:1.221 @@ -782,6 +782,24 @@ void RenderBox::calcHeight() fh = h.value() + borderTop() + paddingTop() + borderBottom() + paddingBottom(); else if (h.isPercent()) { + // Handle a common case: nested 100% height <div>s. + // This is kind of a one-off hack rather than doing it right. + // Makes dbaron's z-index root bg testcases work. Bad dave. - dwh + RenderBlock* cb = containingBlock(); Length ch = containingBlock()->style()->height(); - if (ch.isFixed()) + while (cb && !cb->isTableCell() && ch.isPercent() && ch.value() == 100) { + cb = cb->containingBlock(); + ch = cb->style()->height(); + } + + if (cb->isCanvas()) { + // Don't allow this to affect the canvas' m_height member variable, since this + // can get called while the canvas is still laying out its kids. + // e.g., <html style="height:100%">etc. -dwh + int oldHeight = cb->height(); + static_cast<RenderCanvas*>(cb)->calcHeight(); + fh = h.width(cb->height()) + borderTop() + paddingTop() + borderBottom() + paddingBottom(); + cb->setHeight(oldHeight); + } + else if (ch.isFixed()) fh = h.width(ch.value()) + borderTop() + paddingTop() + borderBottom() + paddingBottom(); } @@ -1189,6 +1207,5 @@ void RenderBox::calcAbsoluteVertical() m_y = t + mt; - //qDebug("v: h=%d, t=%d, b=%d, mt=%d, mb=%d, m_y=%d",h,t,b,mt,mb,m_y); - + //qDebug("v: m_height = %d, h=%d, t=%d, b=%d, mt=%d, mb=%d, m_y=%d",m_height,h,t,b,mt,mb,m_y); } --- kdelibs/khtml/ChangeLog #1.92:1.93 @@ -1,2 +1,7 @@ +2003-11-15 Zack Rusin <zack@kde.org> + + * rendering/render_box.cpp (calcHeight): correctly compute the + height for relatively positioned object with percentage based + dimensions - pretty much a merge from safari (#53902) 2003-11-14 Germain Garand <germain@ebooksfrance.org>