【发布时间】:2018-07-04 08:32:13
【问题描述】:
我正在使用粘性页脚。默认情况下,页脚为position:fixed。当页面到达底部时,它将变为position:sticky。
它在 chrome 和 firefox 中运行良好。但不能在 IE11 中工作。即使到达页脚后仍保持为position:fixed。我认为 IE11 是否不支持 sticky。我有什么解决办法吗?
检查以下代码:
$(document).scroll(function() {
checkOffset();
});
function checkOffset() {
if ($('#sticky').offset().top + $('#sticky').height() >=
$('.bottom_two').offset().top - 10)
$('#sticky').css({
'position': 'sticky',
'transiton': 'position 0.4s'
});
if ($(document).scrollTop() + window.innerHeight <
$('.bottom_two').offset().top)
$('#sticky').css({
'position': 'fixed',
'transiton': 'position 0.4s'
}); // restore when you scroll up
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="sticky" class="stick">
<div class="container">
<div class="bo_wrap">
<div class="bo_wrap_left">
<a class="bot_down testride" href="#buy_ride"></a>
<a class="bot_down downl" href="#" target="_blank"></a>
</div>
<div class="clear_both"></div>
</div>
</div>
</div>
<div class="bottom_two">
<div class="container">
<p>company 2017. all rights reserved.</p>
</div>
</div>
【问题讨论】:
-
它IE11不支持你可以使用Polyfill
-
我给你做了一个sn-p。请完成它以制作minimal reproducible example
标签: javascript jquery html css internet-explorer