i have a little problem with page scrolling... I wanna to change some css when i'm scrolling page down and if window have 100px from top position... This is my code. Much thx for help.
$(document).ready(function(){
$(window).scroll(function(){
if ($(window).scroll(100)){
$('.ufo').css('right','800px');
}
});
});
Use position fixed. Position fixed makes it so that an element stays at it's specified place even if the user scrolls up or down.
window. scrollTo( value-x, value-y ); Here value-x is the pixel value of the width, where you wanna jump or scroll to. value-y is for the height of the window in terms of the pixel where you wanna jump or scroll to.
An element with position:fixed is fixed with respect to the viewport. It stays where it is, even if the document is scrolled.
Try this:
$(document).ready(function(){
$(window).scroll(function(){
if ($(window).scrollTop() > 100){
$('.ufo').css('right','800px');
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With