编辑此表达式以将固定底部变成固定顶部
这个功能应该在iPhone中工作,
$(document).ready(function() {
$('#head').css('position','fixed');
window.onscroll = function() {
document.getElementById('head').style.top =
(window.pageYOffset + window.innerHeight + 25) + 'px';
// alert((window.pageYOffset + window.innerHeight - 25) + 'px');
};
});
但它应该将div(25px)保留在页面底部,我需要它在页面顶部,无论我滚动多少,
我都像这样,
$(document).ready(function() {
$('#head').css('position','fixed');
var height = $('#head').height();
window.onscroll = function() {
document.getElementById('head').style.top =
(window.pageYOffset) - height + 'px';
// alert(window.pageYOffset); alert(window.innerHeight);
};
});
但似乎#head div 没有正确跟随滚动(看起来像是弹跳),知道我错过了什么吗?
this function is supoused to work in iphone,
$(document).ready(function() {
$('#head').css('position','fixed');
window.onscroll = function() {
document.getElementById('head').style.top =
(window.pageYOffset + window.innerHeight + 25) + 'px';
// alert((window.pageYOffset + window.innerHeight - 25) + 'px');
};
});
but it's supoused to keep the div (25px) at the bottom of the page, i need it on top of the page no matter how much i scroll
i'm tring like this
$(document).ready(function() {
$('#head').css('position','fixed');
var height = $('#head').height();
window.onscroll = function() {
document.getElementById('head').style.top =
(window.pageYOffset) - height + 'px';
// alert(window.pageYOffset); alert(window.innerHeight);
};
});
but it seems that the #head div is not following properly the scroll (it seems like it bounces), any idea what i'm missing??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
位置
固定
在 iPhone 中不起作用。因此,每当您滚动页面时,它都会弹起,直到滚动处理程序设置其新位置。Position
fixed
do not work in iPhone. So it is bound to bounce whenever you scroll the page until thescroll
handler set its new position.尝试更多 jQuery:
window.onscroll = function() { $('#head').offset(0,0); }
Try a little more jQuery:
window.onscroll = function() { $('#head').offset(0,0); }