I have been creating a layout system in Javascript for application windows... The Javascript produces the code listed below...
Everything is working really well, except Firefox seems to have different rules for CSS tables than other browsers.
It seems that Webkit browsers set the context for sizing CSS table-cell elements to the nearest relatively/absolutely positioned parent element, just like normal elements, and from this we can treat each cell as a new context for sizing and positioning things absolutely.
Firefox does not appear to do it this way.
Here's sample code:
<div class="header"></div>
<div class='table'>
<div class='row'>
<div class='cell'>
<div class='wrap'>
<div class='pane'>
Content here that is long enough to wrap at the sides. Content here that is long enough to wrap at the sides. Content here that is long enough to wrap at the sides. And still hit the bottom.
</div>
</div>
</div>
<div class='cell' style='background-color:orange; width:230px;'>
cell2
</div>
</div>
</div>
and css:
.header {
height: 50px;
width: 100%;
background: blue;
}
.table {
width:100%;
height:200px;
display:table;
}
.row {
display:table-row;
}
.cell {
display:table-cell;
background-color:red;
position:relative;
}
.wrap {
display:block;
position:absolute;
background-color:purple;
width:100%;
height:100%;
}
.pane {
background-color:green;
height:100%;
width:100%;
position:absolute;
}
Which can be viewed here: http://jsfiddle.net/XmUZ7/3/
This viewed in Webkit (Safari/Chrome) vs. Firefox/Mozilla exemplifies the issue.
I've tried adding a .wrap element into the cell but it doesn't seem to help reset the context. Am I thinking of this the wrong way? Other posts on SO seem to imply that the cell or the .wrap needs to be an inline-block, but those also don't seem to work.
Here are some other links related to this:
Positioning context on table-cell element in Firefox
css absolute position inside table-cell: strange Firefox display
CSS Positioning Absolute within table cells not working in Firefox
https://bugzilla.mozilla.org/show_bug.cgi?id=203225
At this point I am considering not supporting firefox because I've spent so many hours trying to fix it. But this seems silly because everything else is working well across browsers except for basic layout!
It feels like either there is a magic bullet I'm missing or that Firefox has deep design issues that will not allow this.
I think JSFiddle has gotten around this issue by using iframes and no tables at all in its layout, but it does imply there are bugs being avoided.