Note that there are some explanatory texts on larger screens.

plurals
  1. POSafari: table-layout: fixed in absolutely positioned element doesn't stretch parent
    primarykey
    data
    text
    <p>I have a <code>div</code> with <code>display: table; table-layout: fixed; width: 100%</code> as a child of another <code>div</code> with <code>position: absolute</code>. On Chrome, IE, and Firefox, the child div with <code>table-layout: fixed</code> makes the parent <code>div</code> expand to <code>100%</code>, but in Safari (6.0.4, OS X 10.8.3) this doesn't happen. Here's a picture</p> <p><img src="https://i.stack.imgur.com/Fn0ME.png" alt="Safari rendering problem"></p> <p>and a jsbin <a href="http://jsbin.com/oqupah/6/edit" rel="nofollow noreferrer">http://jsbin.com/oqupah/6/edit</a> (make sure to open the output in a new window). The markup is something like this:</p> <pre><code>&lt;div style="position:absolute;border: 1px solid black"&gt; &lt;div style="display:table;table-layout:fixed;width:100%;border:1px solid red;"&gt; &lt;div style="display:table-cell;border:1px solid green"&gt;a&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>This is with the HTML 5 and XHTML 1.0 doctypes. I noticed that if I remove the doctype in safari, it will behave like the other browsers, but removing the doctype is not an option.</p> <p>In practice, I had this code when I was implementing an absolutely positioned popup, where the content of the popup is a <code>div</code> with <code>display: table; table-layout: fixed; width: 100%</code>. I want the popup to stretch 100% so that I can easily provide a <code>max-width</code> and that if the window was resized, the popup would shrink accordingly.</p> <p>So I'm guessing this is a bug in Safari? The behavior on mobile safari is the same. Is there something I can add to make it behave like the other browsers?</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.
    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