can't believe i can't do this simply CSS. fixed div but not to window but within div

Joined
12 Feb 2006
Posts
17,367
Location
Surrey
simply want a div to be fixed to the top left of the content so that it floats always on the screen even when scrolled down it'll still be there. i can get it to be fixed on the window so it'll be top left no matter the width, but what i want is it to be within a container that's 700px wide, so it'll be to the left of that and if the page is very wide then it's not lost to the left.

any clues. absolute doesn't work either as that'll not scroll down the page with you.
 
Hmm, I'll try to help. Post your CSS and HTML please, a small paint diagram would be helpful as I had to read your post about 5 times and am still non the wiser as to what you're trying to do. I'll re-read when day breaks. :)
 
So you want it top left of a container?

Put the fixed div into your container and then set position on the container (can be relative). This will make the fixed div relative to the container, rather than the window.
 
So you want it top left of a container?

Put the fixed div into your container and then set position on the container (can be relative). This will make the fixed div relative to the container, rather than the window.

He wants it to stay on the screen when he scrolls down the page by the look of it. Should be possible with Javascript?
 
thanks guys. got it in the end by simply taking away the left: 0; style.

this is simply what i have

#header {
width: 303px;
height: 400px;
position: fixed;
top: 20px;
border-right: 1px solid #de200f;
text-align: right;
}

and it now stays to the left of the container, and the top of the page even when scrolling. voila
 
Last edited:
Back
Top Bottom