Danijel
Danijel

Reputation: 8610

How to position <div> element absolute from browser window?

I have a big html page, which requires lots of scrolling. I'd like to have a <div> element shown absolute to browser window, so that it is always visible, no matter where I scroll the page.

I tried using css for div element position: absolute; but it does not help in this case.

How can it be done?

Upvotes: 0

Views: 143

Answers (4)

Clyde Lobo
Clyde Lobo

Reputation: 9174

You need position: fixed for achieving that

Here is a small tutorial

http://davidwalsh.name/css-fixed-position

Upvotes: 6

Mad Angle
Mad Angle

Reputation: 2330

Use the property,

position:fixed

It is the css property to position the element relative to the browser window

Upvotes: 0

Jacques
Jacques

Reputation: 3774

Use position:fixed

Here is a fiddle you can reference.

http://jsfiddle.net/muLM8/

Upvotes: 1

jasonslyvia
jasonslyvia

Reputation: 2535

Using position:fixed would be a great choice, see DEMO here.

However, for compatibility reason, IE 6 doesn't support position:fixed, you should use some javascript hack to do so.

Upvotes: 0

Related Questions