I'd like to create a header on the page that doesn't move when you scroll the page.
This seems simple, just add "position: fixed" to the style, but then the content appears underneath the header, because the header is "removed from the flow". So the solution I think is to add "margin-top: height" to the content.
Whats the best way to solve this when the height of the header is variable?
I've got a fiddle that demonstrates the problem:
http://jsfiddle.net/waterlooalex/j4Z8F/2/
Providing your browser window is not too large, the content text will scroll below the 'hello world header', the problem is that the first line of text "Lorem ipsum...' is hidden. I've got some comment out javascript that works around the issue.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…