views:

91

answers:

1

I've got my site content inside an 800px-wide div, I'd like that div to be centered on the page until the browser window width extends past certain distance. At that point, I'd like the content to "lock" into place and not continue to center itself, staying a fixed amount from the left edge.

For example, if the viewers window is 900px wide, then they will see my 800px content centered. If the viewers window is 1400px wide, they will see my content 400px from the left side, locked in that spot.

You might be thinking this is a weird question to ask, and it is! But it's fairly integral to my design for it to work this way. Thanks!

+1  A: 

Setting the container element's max-width to 1700px (900 + 400 * 2) will ensure that the content is never more than 400px away from the left side, provided that the container is not centered itself.

Reinis I.
Note max-width will not work in IE6
Andy E
Excellent, thanks for the quick response. Now, to make things more complicated, I want a background image to be attached to the content and function in the same way. If I put the background in the content, it doesn't extend beyond the set width, how can I get around this?
fr0th
You could just apply the background to the container and center it. It would be positioned the same way as the content, becoming left-aligned with larger screen resolutions.
Reinis I.