質問

I have a div with applied property position: fixed;. I need to stop this property on some height of screen scroll. Any ideas? I just need the css code only.

役に立ちましたか?

解決

You can do it with jQuery pretty easily:

$(window).scroll(function(){
   if ($(window).scrollTop() >= target) {  // change target to number
      $("#el").css('position', 'relative');
   }
});

or pure JavaScript:

window.onscroll = function(){

   if(window.scrollY >= target) { // change target to number
      document.getElementById('el').style.position = 'relative';
   }

};
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top