Forums
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
how it is possible to make a page where when we scroll down the Menu become the header and Fixed also
Position: sticky.
no dude it will not gona work
You need to explain your requirements more clearly.
Then you need to be more specific.
Something like this probably: http://codepen.io/senff/pen/ayGvD
@Senff, I tried using the codes, but it’s not working. Is there jquery plugin link I need to include?
@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.
Here is my [version.](http://codepen.io/codegraphics/pen/fLpaH “”) But it’s not working. Is there something am missing in the jquery code?
You guys or so weird about links. Your actually posting “why mine doesn’t work” when I showed how in a copy and paste. Weird.
If you want me to click on your website link, am not going to do that.
@CodeGraphics, include jQuery :)
Btw, you won’t have IE support with window.scrollY
.
@Crocodillon, any jquery version?