Question

I'm trying to position a div at the top left corner of the page, and I want it to stay there regardless of browser window resizing or page scrolling.

How can I do this either with plain CSS (if possible), or with jQuery?

Was it helpful?

Solution

use css position: fixed;

#fixedDiv {
    position: fixed;
    left: 20px;
    top:20px;
    width: 50px;
    height: 50px;
}

For IE6, see http://www.cssplay.co.uk/layouts/fixed.html

OTHER TIPS

css-selector {
    position: fixed;
    top: 0;
    left: 0;
}

Take care of the z-index. Higher = foreground.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top