Closed Bug 69927 Opened 24 years ago Closed 23 years ago

CSS margin-left:auto; margin-right:auto won't center images or forms.

Categories

(Core :: CSS Parsing and Computation, defect)

x86
All
defect
Not set
normal

Tracking

()

VERIFIED INVALID

People

(Reporter: ronbu, Assigned: pierre)

References

()

Details

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; 0.8) Gecko/20010222
BuildID:    2001022209

The use of margin-left:auto; margin-right:auto is not centering images
and forms on this page.  A couple of tables (including the CrossSearch table of
images) are being centered by this method, and the SalukiSearch.Com form is
being centered withing DIV tags which are set to text-align:center .

Reproducible: Always
Steps to Reproduce:
1.Set an image or form with the CSS properties: margin-left:auto; margin-right:auto;
2.
3.

Actual Results:  The images and forms were flushed to the left.

Expected Results:  The images and forms should have been centered.
*** Bug 69930 has been marked as a duplicate of this bug. ***
When you set class="iCenter" on the <form> elements, you get exactly what you
want -- the <form> element is centered, with margins equal to 0 and width equal
to the width of the containing div.

For the image, it is getting auto margins but is an inline element.. so the auto
margins are probably 0.

margin:auto does _not_ center the element it is applied to.  It just makes the
margins "stretchy" if necessary...  You probably need to use something else here.

Over to Style system for triage
Assignee: asa → pierre
Component: Browser-General → Style System
OS: Windows 98 → All
QA Contact: doronr → ian
for inline images you want to use "text-align: center" or "display: block".

Does this cover everything that this bug was about? Or is there still a bug 
here?
Whiteboard: INVALID? what's the bug?
I have changed the web page at http://members.truepath.com/ron/searchM.html, to
center forms with div tags set to text-align:center .  I am also now setting
images to "display:block; margin-left:auto; margin-right:auto".  This page now
displays well in Mozilla.  In contrast, IE 5.5 does not center the images and
tables which are not surrounded by block level tags set to "text-align:center".
IE screws up a lot of W3C standards complience. If this now displays well I am
going to mark this INVALID since IE is not our problem (gotta bug them to make
them work on standards complience). Reporter, just to make sure this is now an
IE problem not ours?
Marking INVALID due to lack of response & comments that were made earlier.
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago
Resolution: --- → INVALID
Whiteboard: INVALID? what's the bug?
VERIFIED as per comments.
Status: RESOLVED → VERIFIED
This is actually a dup of bug 19686 (also invalid).
Relevant spec: http://www.w3.org/TR/REC-CSS2/visudet.html#q5.  "[For] inline, 
replaced elements, a specified value of 'auto' for 'left', 'right', 'margin-
left' or 'margin-right' becomes a computed value of '0'."
You need to log in before you can comment on or make changes to this bug.