Right (center) align DIV in firefox

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Right (center) align DIV in firefox

Post by alex.barylski »

This works wonderfully in IE but of course not firefox and/or I assume other compliant browsers?

Code: Select all

           <div style="margin: auto 0; text-align: center">            <div style="background-color: white; border: 4px solid white; width: 400px; height: 30px">              Make this right align in FireFox?            </div>          </div> 
Apparently (from googling) FF and others should use margin-left: auto in order to center a DIV within another DIV

But how do you go about right aligning, etc?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Right (center) align DIV in firefox

Post by pickle »

What exactly do you want? The text right aligned within the the inner div, which is itself centered in the outer div?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Right (center) align DIV in firefox

Post by alex.barylski »

I have a container DIV

and inside that DIV I have another DIV which is only 200px wide and a 6 pixel border. Inside this DIV I have a INPUT and BUTTON element.

Code: Select all

<div>  <div style="width: 200px; background-color: white; border: 6px solid #eaeaea">    <input type="text" style="border: 0px" />    <button style="border: 0px">GO</button>  </div></div> 
Applying the text-align: right in the container DIV works in IE but fails in FF. I am trying to get the inner DIV (and it's elements) to align flush with the right side of the document.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Right (center) align DIV in firefox

Post by pickle »

What about playing with the position & right properties?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Right (center) align DIV in firefox

Post by alex.barylski »

I believe I tried those but only on the <input> and <button> when applied to the inner DIV had no effect.
Post Reply