Closed Bug 310363 Opened 19 years ago Closed 19 years ago

text-align broken when width of float'ed element changes (because of image load)

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: robert, Unassigned)

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7 This bug occurs with a fairly common HTML structure - a floated DIV that contains an image and some center-justified caption text. Reproducible: Always Steps to Reproduce: 1. Open the attached example. Notice that the left caption text is left-aligned, while the right caption text is centered below the image. 2. Reload the page. Notice that both captions are now centered 3. Ctrl-reload the page. Notice that the alignment reverts back to the state described in step 1. Expected Results: If you look at the HTML, you'll see that both captions should be centered below the image. I believe this problem is caused by the layout engine not recognizing that the width of the floated element needs to change once the width of the image is known. When the page first loads - before the image has been fetched - the caption text is layed out according to the derived width of the div (which is just the width of the caption text.) However, once the image loads, the DIV width changes, but the caption text position/width is not adjusted accordingly. When the page is loaded a 2nd time, the image is cached and so the browser correctly lays out the caption correctly. A possible workaround for this is illustrated in the HTML that renders the right-hand DIV: Just explicitely set the width of the IMG.
Attached file Test case
Whups, step 3 should be "shift-reload", not "ctrl-reload"
Confirmed in 1.0.7, but worksforme in 1.5b1/trunk. The layout engine in 1.0.x is from the spring of 2004, and 1.0.x is only getting security fixes now, so it's already (probably long since) fixed for the next release, but won't be fixed for a hypothetical 1.0.8.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: