Home › Forums › CSS › Menu become Fix header on scroll › Re: Menu become Fix header on scroll
@CodeGraphics: no, this should work. Can’t say what’s wrong unless I see how you’ve done it.
I would suggest to give the code a better look and see/understand what it’s actually doing. In general, that’s a great way to learn new things (as opposed to “not working. help.” — not implying that that’s what you’re saying, but generally speaking).
Basically, when the window scrolls, the function scroll() is executed. This function calculates the original top coordinate of the element with class “menu”, and the position of the window scrolled.
If those are the same (which means the menu is at the top of the screen), it will get a class called “sticky”.
Class “sticky” makes the element sit, sticky and all, at the top of the screen.
As you can see, by deconstructing the code, no plugin is required.