text-align by definition is for aligning text.
A <div> element is *not* text.
Therefore text-align should not affect the alignment of the <div> within 
its container, only the text within it.  MSIE is incorrectly "aligning" 
the <div> based on text-align.

Instead, use the CSS constrainment rules: if an element has all but one 
of its box properties set to an explicit length, then that one property 
will have to expand to fill the space of its containing block.

For instance:
div {width:200px;padding:0px;border:0px;margin:0px;margin-left:auto;}

Since everything is constrained except the margin-left, then the left 
margin will expand to fill the extra space within the containing block, 
giving the effect of "right-aligning" the <div>.

It is possible to use this correct method in addition to the incorrect 
"text-align" method to ensure cross-browser compatibility.

Hope this helps
--J



Martin Holmes wrote:

> Hi all,
> 
> If a DIV element contains other, smaller DIV elements, and the parent div
> has "text-align: right" in its style, then presumably the descendant DIVs
> should be aligned against the right side of the parent. This is indeed what
> happens in IE5.5 and IE6, but not in NS (6.01 through 6.2). Here's an
> example:
> 
> http://www.halfbakedsoftware.com/iesvic/website/
> 
> If you click on the "Research" menu item, it should expand to show six
> subitems. In IE these are aligned to the right, but NS seems to ignore this
> setting and align them to the left. Can anyone confirm this is a bug, and if
> so, is there a workaround?
> 
> Cheers,
> Martin
> 
> 
> 



Reply via email to