Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
344 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...