【发布时间】:2011-09-23 14:19:32
【问题描述】:
这是一个 IE7 错误:
我有一张桌子,我推到另一个<tbody>。好的,问题是在单元格内我有一个位置:相对; div 和在这个 div 里面我还有其他几个 position:absolute; div。
问题是它们被渲染得好像父 div 不是位置:相对的,这意味着完全位于屏幕的左上角。为什么?!?!
在 ff,chrome 中它工作正常,但在 IE7 中我得到了这些烦人的东西。我已经尝试将 hasLayout 放在任何地方,但它不起作用。
这是我所拥有的:
<table>
<thead></thead>
<tbody id="mtbody">
</tbody>
</table>
这是我收到并推送到“mtbody”(示例)的内容:
<table id="testando">
<tr>
<td hasLayout="true" class="uhr sl" colspan="7" style="border-bottom: dashed 1px #dddddd; background-color: #eeffee;">
<div style="overflow: hidden;" class="holdU" hasLayout="true" betriebsId="83113" betriebsName="2nd Level">
<div hasLayout="true" class="uhr filled0sl" style="width: 679px; left: 0px;">
</div>
<div hasLayout="true" class="border" style="left: 96">
....
所以“holdU”类是 position:relative,而“uhr”类是 position: absolute,它们现在就在我的左上角,有点不可见。
我该如何解决这个问题?
更新:
所以基本上这是预期的结果:http://jsfiddle.net/kgT6E/(来自 DanielB)。但我不明白。想象一下,这个绿色方块现在距离边界 100px,但不是包裹红色方块,而是停留在左上角,因为 position: relative from the green square 没有任何效果。
这是我用来将东西加载到表中的代码:
$.get(savedUrl, function(res) {
var div = $("<div>").html(res);
// this is because I get other stuff together, but what I really want is the tbody content.
$("#mtbody").html($(div.find("tbody").get(0)).html());
});
之前,我将所有内容加载到 tbody, $("#mtbody").load(savedUrl)
但是 IE7 无法识别 TR 和 TD,所以我不得不将它们包装在一个表格中。现在我从 position:absolute divs 得到这个奇怪的定位。
UPDATE2:我已尝试放置所有单位 (23 px ),但到目前为止没有运气。我认为这是因为我必须先将它包装在一个 div 中,当我这样做时,位置不会更新.. 来自 IE 的非常奇怪和讨厌的错误.. =/
【问题讨论】:
-
你能想出一个简单的例子来演示 jsfiddle.net 上的这种行为吗?
标签: html css internet-explorer-7 internet-explorer-6