【发布时间】:2011-04-25 16:20:07
【问题描述】:
我有以下标记:
<nav id='tab_links'>
<a href='#view1'>One</a>
<a href='#view2'>Two</a>
</nav>
<div id='container'>
<div id='view1'>Short Content</div>
<div id='view2'>Much longer content</div>
</div>
<footer>
<input type='submit' />
</footer>
以及以下样式:
#view2 { display: none; }
#footer { display: block; clear: both; text-align: right; }
#footer * { display: inline-block; text-align: center; }
我使用以下 jQuery 交换视图:
$('#tab_links a').click(function() {
var tabToShow = $($(this).attr('href'));
var otherTabs = tabToShow.siblings();
tabToShow.show();
otherTabs.hide();
});
当我将 view1 内容换成 view2 内容时,页脚保持在原来的位置,悬停在新内容的中间上方。如果我将鼠标悬停在页脚内容上,它会跳下到位。如果我随后将内容恢复为view1,页脚将再次停留在view2 的位置,这远低于container 的末尾。
我可以应用哪些样式来使 IE 正确地重新定位页脚?我已经尝试了以下所有方法,各种组合:
- 申请
clearfix到#container - 申请
clearfix到#footer - 申请
height: auto到#container - 申请
height: 30px到#footer input - 申请
widgth: 100px到#footer input
【问题讨论】:
-
我还尝试在
#container中添加<div style="clear:both;"></div>。这也无法在内容扩展时将页脚向下推(或在内容收缩时将其向上推)。这让我怀疑这不是浮动问题。 -
我还尝试链接切换视图的隐藏/显示事件。
$('#view1').hide(0, function() { $('#view2').show(); });的行为与 $('#view1').hide(); 相同$('#view2').show();` -
这个问题似乎非常密切相关:forum.jquery.com/topic/force-ie-redraw(唉,它没有解决)
标签: jquery css internet-explorer clearfix