Using css to implement position fixed

  node.js, question

How to achieve this page effect through position fixed: at the beginning, a component I built was fixed at a certain position on the page, not at the top. when the slider scrolls, this component will slide to the top of the page. How can this effect be achieved? If you use position fixed, it is not fixed at the top at the beginning, will it not look strange when sliding? Do you have any good solutions? Or other methods will do, thanks first.

This requires js to detect the distance between the element and the top. once the distance reaches 0, js is used to set the position fixed in the css of the element