To achieve the desired result, you should use a slightly different structure for your part of HTML. I ran into the same problem and I used the solution as described in this:
http://jsfiddle.net/92y9L/
Associated Code:
CSS
*{ margin:0; border:0; padding:0; } .outer { position:relative; width:250px; height:350px; border:1px dotted black; margin:-1px; } .tbl { display:table; width:100%; height:100%; } .tr { display:table-row; } .td { display:table-cell; margin:0 auto; text-align:center; } .tr .body-outer { height:100%; width:100%; } .body-outer { position:relative; } .body-inner { position:absolute; top:0; right:0; bottom:0; left:0; overflow-y:auto; overflow-x:auto; } .stretch-x { width:100%; } .stretch-y { height:100%; }
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <body> <div class="outer"> <div class="tbl"> <div class="tr" style="background-color:Red;"> <p>test paragraph. This is used as placeholder<br />new line....</p> </div> <div class="tr stretch-y" style="background-color:Gray;"> <div class="td stretch-y" style="background-color:Blue;"> <div class="body-outer" style="background-color:Green;"> <div class="body-inner"> <p style=" white-space:nowrap;">test paragraph. This is used as placeholder<br />new line....</p> <p>test paragraph. This is used as placeholder</p> <p>test paragraph. This is used as placeholder<br />new line....</p> <p>test paragraph. This is used as placeholder</p> <p>test paragraph. This is used as placeholder<br />new line....</p> <p>test paragraph. This is used as placeholder</p> <p>test paragraph. This is used as placeholder<br />new line....</p> <p>test paragraph. This is used as placeholder</p> <p>test paragraph. This is used as placeholder<br />new line....</p> <p>test paragraph. This is used as placeholder</p> <p>test paragraph. This is used as placeholder<br />new line....</p> <p>test paragraph. This is used as placeholder</p> <p>test paragraph. This is used as placeholder<br />new line....</p> <p>test paragraph. This is used as placeholder</p> <p>test paragraph. This is used as placeholder<br />new line....</p> <p>test paragraph. This is used as placeholder</p> <p>test paragraph. This is used as placeholder<br />new line....</p> <p>test paragraph. This is used as placeholder</p> <p>test paragraph. This is used as placeholder<br />new line....</p> <p>test paragraph. This is used as placeholder</p> </div> </div> </div> </div> <div class="tr" style="background-color:Red;"> <p>test paragraph. This is used as placeholder<br />new line.</p> </div> </div> </div> </body>
The concept of this approach is to use an internal css table with three rows of the css table under the borders of the external container. The top line of css is used to place the header, and the bottom line is to place the footer. Both of them have automatic sorting based on their contents.
The middle row, which is used as a container for the body, is stretched by setting the height to 100%. For the internal content of the css row "body", the external relative / internal absolute layout method was used to force the content to be set inside the borders of the css "body" string and allow overflow. The css table intermediate cell is required by IE to fulfill the stretch requirement.
This design works fine with FF + Chrome + Opera + Safari, but IE refuses to calculate the height of the body content relative to its ancestor, the css table row, and it continues to correlate it with the height of the external case. This is exactly the problem I am facing.
In general, if there is no problem, if IE shifts the contents of the body, this solution may be useful for you.
source share