Usually, we can set a parent element to be the context for a child’s absolute positioning, as follows:
#parent {
position: relative;
}
#child {
position: absolute;
top: 0;
left: 0;
}
This all works fine, but when the parent has its display property set to table-cell, it doesn’t work in Firefox. The positioning context for the child element will be the closest positioned ancestor above its parent.
Of note, this works everywhere else. Tested in IE8, IE9, Safari, Chrome & Opera.
See the fiddle here: http://jsfiddle.net/RZ5Vx/
Also, see this fiddle with the parent’s display set to inline-block, which does work in Firefox.
So, is this a bug? If so, is there anyway to work around it?
A
table-cellis meant to be inside atable, so:See this working Fiddle!
Note:
Since you don’t have a
tablein there, set it.You can see this quirksmode for the The display declaration.
EDITED
From the W3C recommendation :: Tables it reads
This is not a bug, is more like a status-bydesign thing! Please see this!
EDITED
To include the work around placed on the comment as requested on the question:
Possible work around are:
Wrap the element with a
divasposition:relative;See Fiddle!Note: most practical solution!
Wrap the inner elements with a
divasposition:relative;See Fiddle!Note: requires some definitions from the original element to be declared on the innerWrapper!