Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS absolute div inside relative parent for Firefox [duplicate]

Tags:

css

firefox

I'm trying to position a div inside a table. The parent has position: relative while my div las position: absolute. I usually develop in chrome and it works just fine there but when I open firefox my absolute div ignores it's parent and occupies the whole page.

Here's an example which works in chrome but not in firefox: http://jsfiddle.net/pdFSh/

Any ideas?

like image 464
Romeo Mihalcea Avatar asked Jul 05 '13 11:07

Romeo Mihalcea


2 Answers

You'll need to change the display value of #absolute's parent:

table tr#body td { display: block; }
like image 154
André Dion Avatar answered Oct 08 '22 13:10

André Dion


It was the known bug of Firefox (fixed since Firefox 31). Before it was fixed, the common workarounds were nesting the div inside the table cell and setting position: relative to it, or changing the display of the cell itself to display:block (which converts the cell to a div-like block box nested in the anonymous table cell box). The second approach seemed to be applicable in this case because the height of the cell is fixed.

like image 37
Ilya Streltsyn Avatar answered Oct 08 '22 12:10

Ilya Streltsyn