# Sticky Header Visual Trick

Sticky headers seem to be very popular now, but most of them rely on scroll events. One bad thing about relying on the scrolling event is that mobile safari doesn't execute the function that is attached to the event until after the browser is done scrolling. There is also the `position:sticky` , but it isn't widely supported yet.

What you see here is a little visual trick (hack) to do something similar to what you might see in a sticky header. This requires two headers in the markup. This is probably really bad for SEO. Anyways, I have the JS duplicate the menu markup so I don't have to write it twice. The main header is `position:relative` while the sticky header is `position:fixed` . The main one has a higher z-index that the sticky header.

I find that the interaction looks better when the main header is much bigger than the sticky one. Also, having more space between the main header and the content is better. Also, the page needs to be long enough so that the main header clears when you scroll all the way.