This question has already been answered:

There is one block that can be seen not immediately, only after scrolling the page. It is necessary to make it so that after the appearance of this block it becomes "fixed".

.block{ margin-top:30%; width:40%; float:right; position:fixed; z-index: 10; } 

Reported as a duplicate by Grundy , aleksandr barakin , D-side , Qwertiy , PashaPash Mar 30 '16 at 9:52 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • what is the problem? what have you tried to do? - Grundy
  • when I did, the block was immediately fixed, but it was necessary that after scrolling - Anton Perehrest
  • @ AntonPehrest add HTML and CSS to the question text, please. - Dmitry Shevchenko

1 answer 1

Something like this jQuery ( http://jsfiddle.net/5n5MA/2/ )

 var fixmeTop = $('.fixme').offset().top; $(window).scroll(function() { var currentScroll = $(window).scrollTop(); if (currentScroll >= fixmeTop) { $('.fixme').css({ position: 'fixed', top: '0', left: '0' }); } else { $('.fixme').css({ position: 'static' }); } }); 

based on