Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a <div> move up and down when I'm scrolling the page?

How can I make a div element move up and down the page when the user is scrolling the page? (where that element is always visible)

like image 201
The Unknown Avatar asked Oct 28 '09 17:10

The Unknown


People also ask

How do I make a div move up and down when I'm scrolling the page?

Just add position: fixed; in your div style. I have checked and Its working fine in my code.

How do I make a div scroll vertically?

Set the overflow-x:hidden; and overflow-y:auto; that will automatically hide the horizontal scroll bar and present only vertical scrollbar. Here the scroll div will be vertically scrollable.


1 Answers

You want to apply the fixed property to the position style of the element.

position: fixed; 

What browser are you working with? Not all browsers support the fixed property. Read more about who supports it, who doesn't and some work around here

http://webreflection.blogspot.com/2009/09/css-position-fixed-solution.html

like image 110
Bob Avatar answered Oct 12 '22 11:10

Bob