468,236 Members | 1,951 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,236 developers. It's quick & easy.

Div alignment

CCC
Hello,

I am attempting to center a div on a page. I have a dumbed down
version of my page here:

<body>
<div id="outercontainer" align="center" style="position:relative;
background-color: #ff0000;">
<div id="innercontainer" style="position:relative;
text-align:left; width:600px; background-color: #fff000;">
This is a test of the two container to see if they stop at the
left
</div>
</div>
</body>

The page centers correctly in Mozilla1.6 and IE6, but when you resize
the browser IE keeps it in the middle until the browser becomes
smaller than the div. Once it becomes smaller than the div, the div
stops moving at the left margin. With Mozilla the div keeps centering
so the div sort of disappears into the left margin. Now the Mozilla
action makes more sense as to why it is doing that, but unfortunately
I would prefer it to do what IE does which is to center the div until
the browser gets resized smaller and then just keep it justified to
the left margin.

Can this be achieved?

Thanks,
Chris
Jul 20 '05 #1
1 4710
Els
CCC wrote:
Hello,

I am attempting to center a div on a page. I have a dumbed down
version of my page here:

<body>
<div id="outercontainer" align="center" style="position:relative;
background-color: #ff0000;">
<div id="innercontainer" style="position:relative;
text-align:left; width:600px; background-color: #fff000;">
This is a test of the two container to see if they stop at the
left
</div>
</div>
</body>

The page centers correctly in Mozilla1.6 and IE6, but when you resize
the browser IE keeps it in the middle until the browser becomes
smaller than the div. Once it becomes smaller than the div, the div
stops moving at the left margin. With Mozilla the div keeps centering
so the div sort of disappears into the left margin. Now the Mozilla
action makes more sense as to why it is doing that, but unfortunately
I would prefer it to do what IE does which is to center the div until
the browser gets resized smaller and then just keep it justified to
the left margin.

Can this be achieved?


Just add a border to the outercontainer :-)
Have it the same colour as the background, and you won't
even have to see it.

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vo. O resto imperfeito.
- Renato Russo -

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Shashi | last post: by
10 posts views Thread by j0mbolar | last post: by
67 posts views Thread by S.Tobias | last post: by
13 posts views Thread by aegis | last post: by
12 posts views Thread by Yevgen Muntyan | last post: by
10 posts views Thread by haomiao | last post: by
55 posts views Thread by fishpond | last post: by
2 posts views Thread by somenath | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.