Skip to content Skip to sidebar Skip to footer

Table With 100% Height Row And Internet Explorer 9

I have the following example:

Solution 1:

As far as I know, Internet Explorer looks up to the first parent element that has hasLayout triggered to calculate the 100% height. This is different from most other browsers. Documentation on Internet Explorer's hasLayout property:

To begin with, there are two sets of elements.

  • Elements that rely on a parent element to size and arrange their contents
  • Elements that are responsible for sizing and arranging their own contents.

In general, elements in Internet Explorer's Dynamic HTML engine are not responsible for arranging themselves. A div or a p element may have a position within the source-order and flow of the document, but their contents are arranged by their nearest ancestor with a layout (frequently body). These elements rely on the ancestor layout to do all the heavy lifting of determining size and measurement information for them.

Note: The element that is responsible for sizing and positioning an element may be an ancestor, not just the element's immediate parent.) The major benefits of each element not having its own layout are performance and simplicity.

A quick way to solve your problem could be to add a wrapper div element within your td, which mimics the size of the td but because of it's nature triggers hasLayout (not tested, jsFiddle on IE8 Compatibility is broken):

<!DOCTYPE HTMLPUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><metahttp-equiv="X-UA-Compatible"content="IE=edge"><metahttp-equiv="Content-Type"content="text/html; charset=ISO-8859-1"><title>Example</title></head><BODY><DIVstyle="height:150px;background-color:#AAAAFF;overflow:auto"><TABLEstyle="height:100%;width:300px"><TR><TDstyle="background-color:orange">Text with an unknown height (22px here)</TD></TR><TRstyle="height:100%"><TDstyle="height:100%;background-color:yellow"><divstyle="height: 100%; width: 100%; position: relative;"><TEXTAREAstyle="height:100%;-moz-box-sizing:border-box"COLS=30ROWS=4>Remaining space (150px with IE9, 122px with others)</TEXTAREA></div></TD></TR></TABLE></DIV></BODY></html>

Solution 2:

Do you require the height:150px; property on you DIV, if not move it to the TABLE:

See here for JSFiddle:

<DIVstyle="background-color:#AAAAFF;overflow:auto"><TABLEstyle="height:150px;width:300px"><TR><TDstyle="background-color:orange">Text with an unknown height (22px here)</TD></TR><TRstyle="height:100%"><TDstyle="height:100%;background-color:yellow"><TEXTAREAstyle="height: 100%; width: 100%; -moz-box-sizing: border-box; border: 0pt none; padding: 0pt; margin: 0pt;">Remaining space (150px with IE9, 122px with others)</TEXTAREA></TD></TR></TABLE></DIV>

Solution 3:

<!DOCTYPE HTMLPUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><metahttp-equiv="X-UA-Compatible"content="IE=edge"><metahttp-equiv="Content-Type"content="text/html; charset=ISO-8859-1"><title>Example</title></head><BODY><DIVstyle="height:150px;background-color:#AAAAFF;overflow:auto"><TABLEstyle="height:100%;width:300px"><TR><TDstyle="background-color:orange">Text with an unknown height (22px here)</TD></TR><TRstyle="height:100%"><TDstyle="height:100%;background-color:yellow"><TEXTAREAstyle="height: 100%; width: 100%; -moz-box-sizing: border-box; border: 0pt none; padding: 0pt; margin: 0pt;">Remaining space (150px with IE9, 122px with others)</TEXTAREA></TD></TR></TABLE></DIV></BODY></html>

Solution 4:

Maybe this code help you...

I test it at jsfiddle: http://jsfiddle.net/mHTTM/5/

In IE, if you wearing 100 percent in child tag, width/height will be the same as the top parent tag's width/height. Not the parent tag. So you just need to change child tags from percent to pixel.

<DIVstyle="height:150px;background-color:#AAAAFF;overflow:auto"><TABLEstyle="height:100%;width:300px"><TR><TDstyle="background-color:orange">Text with an unknown height (22px here)</TD></TR><TRstyle="auto"><TDstyle="height:122px;background-color:yellow"><TEXTAREAstyle="height:100%;-moz-box-sizing:border-box"COLS=30ROWS=4>Remaining space (150px with IE9, 122px with others)</TEXTAREA></TD></TR></TABLE></DIV>

Post a Comment for "Table With 100% Height Row And Internet Explorer 9"