Page 1 of 1

Right (center) align DIV in firefox

Posted: Wed Apr 29, 2009 9:54 am
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?

Re: Right (center) align DIV in firefox

Posted: Wed Apr 29, 2009 9:56 am
by pickle
What exactly do you want? The text right aligned within the the inner div, which is itself centered in the outer div?

Re: Right (center) align DIV in firefox

Posted: Wed Apr 29, 2009 10:47 am
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.

Re: Right (center) align DIV in firefox

Posted: Wed Apr 29, 2009 11:28 am
by pickle
What about playing with the position & right properties?

Re: Right (center) align DIV in firefox

Posted: Thu Apr 30, 2009 7:34 am
by alex.barylski
I believe I tried those but only on the <input> and <button> when applied to the inner DIV had no effect.