Reputation: 563
I've written an example here
I want a header bar on the top of the page.
<p style="vertical-align: middle; color: white">Head Bar</p>
And when user scrolls down and up, the header bar will always be on the top.
But now it has an issue that the bottom of the page will be cut-off.
Just like the example above, the
"Title 3",
"Content 3.",
"Author: Alex"
will be cut-off.
Anyone has any ideas about this issue?
Thanks in advance.
Eric
Upvotes: 8
Views: 40395
Reputation: 2521
You actually can achieve it simpler than that. You only need to set your header div with position: fixed
, and a 'push' div to, well... push the content down.
Take a look in this Fiddle
Upvotes: 13
Reputation: 1914
You should set your header bar to position: fixed
instead.
Example:
div.header {
position: fixed;
top: 0;
left: 0;
right: 0;
}
if you are concerned about the top of .home being cut off, you can also add a margin-top
Upvotes: 3