In Yahoo website, when scroll down, a blue part is fixed to the top, while if not scroll down, the blue part is not fixed.
How to implement this ?
May I try onScroll
function?
In Yahoo website, when scroll down, a blue part is fixed to the top, while if not scroll down, the blue part is not fixed.
How to implement this ?
May I try onScroll
function?
Yes, you need to bind to win scroll like this:
I use inspect element and, apperantly it changes class when that "blue part" is not in view, so what it is doing (I guess) is changing the classes while it is in view and not in view, you can find if a div is in view and then change accordingly, "onscroll" is a great idea
You can make it fixed just with css.
Use
$(window).scroll(function()
on the part which you want to be fixed.Fiddle Demo : Demo
If you want to apply the fixed part to the header replace the class name in the
$(window).scroll(function(){}):
function.Example for fixed Header while scrolling : Demo-2