Alex Rivera | Logout

Add/remove CSS will cause IE9 to increase the table's height

Asked 2011-04-26T10:01:05.950
35

I add a mouse event to the HTML TR when user mouse-over/out the TR to change some CSS color. But in IE9 seems to have an issue that the table's height will keep increasing each time the CSS changed.

Note: the issue only occurs when the horizontal scrollbar appears.

Here is the HTML.

<div style="width:100%;height:100%;">
    <div class="grid">
        <div class="grid-body">
            <table width="100%" cellpadding="0" cellspacing="0" border="0" style="table-layout:fixed;">
                <tbody>
                    <tr>
                        <td style="width:3040px;" class="item">
                            <div>
                                Please mouse-over me and out
                            </div>
                        </td>
                        <td class="item">
                            <div>
                                Please mouse-over me and out
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>

Here is the Javascript

$(document).ready(function (){
 $('.item').mouseover(function () {
     $(this).parent().addClass("item-over");
 }).mouseout(function() {
     $(this).parent().removeClass("item-over");
 });
 }
);

Here is the CSS setting

 html, body {height:100%}
 body {
     margin: 0; padding: 0 5px;
 }
 div.grid {
     background: #DAE7F6; border: 1px solid #86A4BE; overflow: hidden; zoom: 1;
 }
 div.grid-body {
     background: red; border: 0; overflow: auto; width: 100%; position: relative;
 }
 tr.item-over {
     color: #6eadff;
 }

You can run the full example here.

Edit
Report

2 Answers

1

I might have just solved it.

Try:

width: 100%;
display: inline-block;

on the containing element ("div.grid-body" in this case).

answered 2011-06-21T10:36:37.970
0

just to see

div.grid { background: #DAE7F6; border: 1px solid #86A4BE; overflow: hidden; zoom: 1; width:100%; }

what about this:
    width:100% !important; 
answered 2011-06-10T11:19:07.753

Your Answer