Last Comment Bug 450418 - absolute positioning containing block established by relative-positioned fieldsets is misplaced
: absolute positioning containing block established by relative-positioned fiel...
Product: Core
Classification: Components
Component: Layout: Form Controls (show other bugs)
: Trunk
: x86 Windows XP
: -- normal with 13 votes (vote)
: mozilla10
Assigned To: :Ehsan Akhgari
: Jet Villegas (:jet)
: 532368 542650 543052 635773 647169 (view as bug list)
Depends on: 455338 656130 1005791
  Show dependency treegraph
Reported: 2008-08-13 08:31 PDT by Zenich Igor
Modified: 2014-05-15 13:35 PDT (History)
20 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

testcase (544 bytes, text/html)
2008-08-13 09:45 PDT, Dmitri Gribenko
no flags Details
fieldset relative positioning bug (1.04 KB, text/html)
2010-03-10 17:40 PST, Matt Milosavljevic
no flags Details

Description Zenich Igor 2008-08-13 08:31:34 PDT
User-Agent:       Opera/9.27 (Windows NT 5.2; U; ru)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.2; ru; rv: Gecko/2008070208 Firefox/3.0.1

Coordinates count not from the top left corner of the block, but from contents (i.e. move downwards and to the right on size padding-top and padding-left.

Reproducible: Always

Steps to Reproduce:
1. Create a html file with this code in it:
  <fieldset style="width: 300px; height: 300px; position: relative; padding: 20px; border: 1px solid black">
    <span style="position: absolute; top: 0; left: 0">Test word</span>

2. Open created html file with Mozilla.
Actual Results:  
The test word is shifted on 20 pixels at the left and from above.

Expected Results:  
The test word is in the top left corner of the block.
Comment 1 Dmitri Gribenko 2008-08-13 09:45:00 PDT
Created attachment 333579 [details]

Attached testcase.

I can confirm described behavior in latest nightly.

Renders as expected in Konqueror 3.5.9.
Comment 2 David Baron :dbaron: ⌚️UTC-8 2008-09-15 09:32:53 PDT
There aren't any specs that actually say what should happen here, though.  (I'm surprised fieldsets work as absolute positioning containing blocks at all.)
Comment 3 Boris Zbarsky [:bz] (still a bit busy) 2008-09-15 11:10:20 PDT
We set up the fieldset as the abs pos container, but then when inserting the frames we actually stick them inside the -moz-fieldset-content frame.  That's a block, so it can deal, but you get the offset this bug is about.

Once bug 455338 is fixed we should just stop forwarding the absolute list here, and that will fix things.
Comment 4 nemo 2008-09-15 11:14:45 PDT
I have similar behaviour that I suspect is related.
Even though the fieldset in this case is NOT absolutely positioned.

I set the fieldset to relatively positioned, to allow the spinner top/right to be relative to the first positioned parent.

IE6, Opera, Safari, Chrome, Webkit nightly and Konqueror all position both spinners the same distance to the right.

Firefox does not.

This is a little odd since computed styled reports Firefox is fully aware of the dimensions of the fieldset, and the deviation is not great, so I'm not too sure what Firefox is doing.

There are 2 spinners on this test - the first one is relative to the <fieldset>  - that's the one Firefox breaks.  The second one is relative to the <ul> - that one works in Firefox.
Comment 5 nemo 2008-09-15 11:15:24 PDT
Oh. Oops. I see Boris has explained what is happening.
Thanks! :)
Comment 6 John P Baker 2009-12-02 05:41:57 PST
*** Bug 532368 has been marked as a duplicate of this bug. ***
Comment 7 Boris Zbarsky [:bz] (still a bit busy) 2010-01-29 10:38:38 PST
*** Bug 543052 has been marked as a duplicate of this bug. ***
Comment 8 David Baron :dbaron: ⌚️UTC-8 2010-01-29 10:39:42 PST
*** Bug 542650 has been marked as a duplicate of this bug. ***
Comment 9 Boris Zbarsky [:bz] (still a bit busy) 2010-01-29 12:27:07 PST
*** Bug 543052 has been marked as a duplicate of this bug. ***
Comment 10 Boris Zbarsky [:bz] (still a bit busy) 2010-01-29 13:14:01 PST
*** Bug 543052 has been marked as a duplicate of this bug. ***
Comment 11 Matt Milosavljevic 2010-03-10 17:40:10 PST
Created attachment 431763 [details]
fieldset relative positioning bug

This seems to apply in instances where there is no padding on the fieldset. Other browsers seem to treat the fieldset as expected.
Comment 12 gm 2011-01-13 06:41:35 PST
Still happening in latest minefield build 

Mozilla/5.0 (Windows NT 6.1; rv:2.0b10pre) Gecko/20110111 Firefox/4.0b10pre ID:20110111030357

fieldset with position relative
button with position absolute

test case :
paste this code in a html empty file and open it in firefox

<!DOCTYPE html>
	<fieldset style="position: relative">
		<button style="position:absolute; top: 0; right: 0;">should be at top right</button>
				Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean posuere, nibh vitae posuere hendrerit, orci sem ultricies elit, ac ornare orci lorem id ipsum. Sed sed tincidunt augue. Duis interdum volutpat convallis. Praesent id diam augue. Nam lacinia felis nec mauris consequat dictum. Mauris in commodo ipsum. Phasellus tincidunt massa massa. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec molestie ornare vulputate. In justo turpis, volutpat a ultricies non, congue id risus. In viverra velit eget libero mollis mollis ac eget urna. Curabitur fringilla, magna sit amet feugiat dictum, diam orci suscipit arcu, id tempus massa felis vel tellus. Sed quis diam mauris, non aliquet lectus.

actual result : the button is not at top right corner of the fieldset

expected result : the button should be at top right corner
Comment 13 Boris Zbarsky [:bz] (still a bit busy) 2011-02-21 13:44:57 PST
*** Bug 635773 has been marked as a duplicate of this bug. ***
Comment 14 Denis Hoctor 2011-02-21 13:54:25 PST
Here's a quick example:

Taken from Bug 635773
Comment 15 George Gooding 2011-03-18 07:46:47 PDT
I can confirm this bug. Set up two sets of HTML with the same CSS, one using fieldset, one using form; the button is misplaced when inside fieldset but not anything else, works fine in all other browsers.

I set the child element to:

But Firebug reports that Firefox thinks this is:

So the right-position is being halved and inversed... Odd.
Comment 16 George Gooding 2011-03-18 07:51:13 PDT
Forgot to mention that the bottom position variable is also wrong, when top is set to 10px, the bottom is set to -4px, when it should be 7px. So clearly there's some problems with the calculation of absolute position within the fieldset.
Comment 17 nemo 2011-03-18 08:50:06 PDT
George, my workaround was just to put those elements in a wrapper.
<fieldset><div style="position: relative;"><button style="position: absolute">... will do the trick
in my case, it was a spinner.
I just moved it from under <fieldset> to under <fieldset><ul><li> and added a comment noting this bug.
Comment 18 Mats Palmgren (:mats) 2011-04-01 03:27:18 PDT
*** Bug 647169 has been marked as a duplicate of this bug. ***
Comment 19 Tae 2011-06-04 09:30:07 PDT
The nemo's solution works, but if we try to put a <legend> inside the <div>, in Firefox 3.6 the <fieldset> get broken. 

(Sorry for my English.)
Comment 20 :Ehsan Akhgari 2011-09-29 15:08:18 PDT
This was fixed by bug 656130.
Comment 21 Zenich Igor 2011-10-12 04:47:08 PDT
As I can see it has not been fixed.
If you open enclosed testcase: you will be able to see that the bug still exists.
Comment 22 Ryan VanderMeulen [:RyanVM] 2011-10-12 04:57:07 PDT
This was marked fixed for what will become Firefox 10. Are you running a nightly build?
Comment 23 Zenich Igor 2011-10-12 05:09:16 PDT
Sorry for the confusion, I thought that it was fixed for current stable version of Firefox.
Comment 24 RB 2012-01-19 05:58:20 PST
This should be reopened. Zenich's test case is still failing:
Comment 25 Mats Palmgren (:mats) 2012-01-19 06:28:17 PST
RB, please file a new bug if you think there's something wrong with it.
Please check that it's not known already.  Thanks.
Comment 26 nicolas.ternisien 2014-05-04 23:39:55 PDT
I can confirm this bug is still present... and annoying in Firefox 29.0.
Comment 27 Daniel Holbert [:dholbert] 2014-05-15 13:34:34 PDT
Thi(In reply to nicolas.ternisien from comment #26)
> I can confirm this bug is still present... and annoying in Firefox 29.0.

You're seeing bug 942341, which is similar but distinct.
Comment 28 Daniel Holbert [:dholbert] 2014-05-15 13:35:00 PDT
(and a relatively recent behavior-change, rather than this bug being "still present")

Note You need to log in before you can comment on or make changes to this bug.