【发布时间】:2011-08-12 22:08:30
【问题描述】:
当用户将鼠标悬停/移出 TR 以更改某些 CSS 颜色时,我将鼠标事件添加到 HTML TR。但在 IE9 中似乎有一个问题,即每次 CSS 更改时表格的高度都会不断增加。
注意:该问题仅在出现水平滚动条时出现。
这是 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>
这里是 Javascript
$(document).ready(function (){
$('.item').mouseover(function () {
$(this).parent().addClass("item-over");
}).mouseout(function() {
$(this).parent().removeClass("item-over");
});
}
);
这是 CSS 设置
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;
}
您可以运行完整的示例here。
【问题讨论】:
-
9个版本之后,IE还是不能搞定:)
标签: javascript jquery html css internet-explorer