Home jquery Fixing the block at a specific place when scrolling

Fixing the block at a specific place when scrolling

Author

Date

Category

Hello, you need a block to fix when scrolling when Top == 165; I do this:

$ (window) .scroll (function () {
 if ($ (this) .scrolltop () & gt; 165) {
  $ ('# View .fltrow'). CSS ({'Position': 'Fixed', 'Top': '165px', 'z-index': '999'});
 } else {
  $ ('# View .fltrow'). ATTR ('Style', '');
 }
 });

It turns out that the block when scrolling comes to top == 0, then it is sharply fixed on top == 165 (as if the feeling that jumps), but I need that the block does not reach Top: 0; Namely, Top 165 was immediately fixed, how to achieve such a result, I can not find materials in Google, tell me.


Answer 1

has long done such an example: http://jsfiddle.net/alpha9000/wxfb9/
He is also a response to this question: Floating block – How to remove fixation?

Look MB to you.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions