iconic_creator — 2011-05-17T09:13:18-04:00 — #1
Good morning everyone,
I need a way to place an item, say a div or an image over a page. I just saw an example similar to what I am looking for. There is a form at the bottom right corner of the Sitepoint home page. It moves with the window size and does not stay behind.
I tried using a simple CSS only method. By making a div 100 percent wide, absolute positioned and then placed an image in the background. The imaged is positioned to the top right.
This works well but with one problem, when the window is re-sized and you scroll using the horizontal scroll bar the image is left behind in the window.
What are your thoughts?
ralphm — 2011-05-17T09:17:02-04:00 — #2
Your description sounds odd. Do you have a working example? From what you describe, I'd expect the image to follow the div around. We need to see some code at least.
iconic_creator — 2011-05-17T09:27:12-04:00 — #3
Here is an example I just put together. It is a little different.
Because I placed a Div in the absolute positioned div and floated it right:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
margin: 0 auto;
margin: 0 auto;
iconic_creator — 2011-05-17T09:33:26-04:00 — #4
Do you noticed how the red box stays behind when you scroll horizontally when the window is re sized?
ralphm — 2011-05-17T19:32:48-04:00 — #5
I would adjust the CSS to this:
That keeps the red box in the top right corner (where you seem to want it). BUT … if the viewport bets smaller than the 960px of the content box and then you scroll, the box will still stay put. But that's a rare situation. If you remove this
It won't happen any more.
paulob — 2011-05-18T15:27:40-04:00 — #6
You aren't thinking of position:fixed are you?