图像的位置不随窗口滚动而改变 [英] POsition of image not changing with window scroll

查看:97
本文介绍了图像的位置不随窗口滚动而改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当窗口向下滚动但什么都没发生时,我正在使用此代码将图像向下滑动

I am using this code to slide the image down when window is scroled down but nothing is happenning

$('#left_img').css("top",$(window).scrollTop()+"px");




#left_img {
margin:0 0 0 -55px !important;
position:absolute;
top:5px !important;
}

是否有可能找出整个滚动窗口的高度,然后如果图像达到一定高度,则应停止向下滑动

Is it possible to find out how much is height of whole scroll window and then if image reaches certain height then it should stop sliding down

推荐答案

您需要首先实际捕获事件.

You need to actually capture the event first.

$(window).scroll(function() { 
    $('#left_img').css("top", $(window).scrollTop()+"px");
});

我对滚动和定位了解不多,但是如果您不捕获事件,那可能是您的问题.

I don't know much about scrolling and positioning, but if you're not capturing the event, that could be you're problem.

这篇关于图像的位置不随窗口滚动而改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆