Note that there are some explanatory texts on larger screens.

plurals
  1. POFirefox css table cells don't respond like other browsers with position:absolute
    primarykey
    data
    text
    <p>I have been creating a layout system in Javascript for application windows... The Javascript produces the code listed below...</p> <p>Everything is working really well, except Firefox seems to have different rules for CSS tables than other browsers.</p> <p>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.</p> <p>Firefox does not appear to do it this way.</p> <p>Here's sample code:</p> <pre><code>&lt;div class="header"&gt;&lt;/div&gt; &lt;div class='table'&gt; &lt;div class='row'&gt; &lt;div class='cell'&gt; &lt;div class='wrap'&gt; &lt;div class='pane'&gt; 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. &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class='cell' style='background-color:orange; width:230px;'&gt; cell2 &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>and css:</p> <pre><code>.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; } </code></pre> <p>Which can be viewed here: <a href="http://jsfiddle.net/XmUZ7/3/" rel="nofollow noreferrer">http://jsfiddle.net/XmUZ7/3/</a></p> <p>This viewed in Webkit (Safari/Chrome) vs. Firefox/Mozilla exemplifies the issue.</p> <p>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.</p> <p>Here are some other links related to this:</p> <p><a href="https://stackoverflow.com/questions/10902743/positioning-context-on-table-cell-element-in-firefox">Positioning context on table-cell element in Firefox</a></p> <p><a href="https://stackoverflow.com/questions/17808033/css-absolute-position-inside-table-cell-strange-firefox-display">css absolute position inside table-cell: strange Firefox display</a></p> <p><a href="https://stackoverflow.com/questions/11021308/css-positioning-absolute-within-table-cells-not-working-in-firefox">CSS Positioning Absolute within table cells not working in Firefox</a></p> <p><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=203225" rel="nofollow noreferrer">https://bugzilla.mozilla.org/show_bug.cgi?id=203225</a></p> <p>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!</p> <p>It feels like either there is a magic bullet I'm missing or that Firefox has deep design issues that will not allow this.</p> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload