我想我的固定div停止滚动在我的网页上的某个点,但是,我找到的解决方案都没有实际运作正常,并做了我想要的...固定的Div停止在某些点jQuery
这是我目前的jQuery:
var windw = this;
$.fn.followTo = function (pos) {
var $this = this, $window = $(windw);
$window.scroll(function(e){
if ($window.scrollTop() > pos) {
$this.css({
position: 'absolute',
top: pos
});
} else {
$this.css({
position: 'fixed',
bottom: -10px
});
}
});
};
$('#qF').followTo(800);
这是我的HTML:
<div id="qF" class="central theater-dir-adown">
<img src="data/img/prefs/dir_adown" class="dir-adown">
</div>
这是我的CSS:
.theater-dir-adown{
cursor: pointer;
display: inline-block;
position: fixed;
bottom: -10px;
left: calc(100%/2 - 51px);
width: calc(75%/9);
height: auto;
}
.dir-adown{
width: 100%;
}
所以我想要的是停止滚动800px的div #qF
,但我使用的代码不工作,div将继续向下滚动页面。我不确定在我的代码中是否有某种错误,但有人可以帮我解决吗?还是很新的jQuery的..
感谢
滚动删除';''从底部:-10px;' –
@NirmalyaGhosh没有工作,抱歉地说:(仍无法工作,因为我t应该 –
从底部移除'px':-10px'它会抛出错误'Uncaught SyntaxError:Unexpected identifier'。工作:http://output.jsbin.com/latuji –