Table with 100% height row and Internet Explorer 9

后端 未结 5 819
忘了有多久
忘了有多久 2021-02-08 11:43

I have the following example:





        
5条回答
  •  星月不相逢
    2021-02-08 11:52

    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):

    
    
    
    
    
    Example
    
    
    
    Text with an unknown height (22px here)

提交回复
热议问题