I am looking for some code that will allow me to create a sticky header. The only problem is that the element (
) will be positioned mid-page, and will only 'stick' to the top of the viewport only when the user scrolls down and the element actually reaches the top of the viewport.
I expect this to use a minimal amount of javascript. Can anyone help me out and point me in the right direction?
Producing fixed content is pretty straight forward. Checkout the code of my website, http://www.w3a2z.net. It is all about turning off overflow for html, body, inserting the element you want to persist in the viewport, then putting your content into a scrollable div. You have to define html, body{height:100%;width:100%} and #page{height:100%;width:100%} I simply cannot think of a way to scroll and stick though.