Ian Vink
Ian Vink

Reputation: 68740

A DIV that stays at the top while a web page scrolls

How would I have a DIV stay at the top of the page visually as the user scrolls down a web page?

A simple Javascript framework would be great!

it's for this web site: http://BiblePro.BibleOcean.com

Upvotes: 30

Views: 99103

Answers (2)

Amriz khan
Amriz khan

Reputation: 41

That is simple, just make the top Div position and it will work fixed e.g

Start div tag

<div style="position: fixed;background: #336699; width: 100%;">

Be at the top end div tag

Upvotes: 3

Kobi
Kobi

Reputation: 137997

If you don't care about IE6, you can use position: fixed:

div {
  top: 0;
  position: fixed
}

Using jQuery, see this question: What is the simplest jQuery way to have a ‘position:fixed’ (always at top) div?

Upvotes: 49

Related Questions