Note that there are some explanatory texts on larger screens.

plurals
  1. POHorizontal Menu - full width of li's child ul's
    primarykey
    data
    text
    <p>I've got a horizontal menu with table/table-cell tags:</p> <pre class="lang-css prettyprint-override"><code>.menu { display: table; width: 100%; } .menu li { display: table-cell; } </code></pre> <pre class="lang-html prettyprint-override"><code>&lt;!doctype html&gt; &lt;html&gt; &lt;body&gt; &lt;div style="width: 960px"&gt; &lt;ul class="menu"&gt; &lt;li&gt;&lt;span&gt;Selected Menu Item&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#item"&gt;Another Item&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#item"&gt;Another Item&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#item"&gt;Another Item&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is working fine, but I also have submenus like</p> <pre class="lang-html prettyprint-override"><code>&lt;ul class="menu"&gt; &lt;li&gt;&lt;span&gt;Selected Menu Item&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#item"&gt;Another Item&lt;/a&gt; &lt;ul class="submenu"&gt; &lt;li&gt;&lt;a href="#sub"&gt;Submenu Item&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#sub"&gt;Submenu Item&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Now normally I would just make the first-level li's <code>position: relative</code> and the second-level ul <code>position: absolute</code> and give it the same size as I gave the li-elements; but in this case I do not have a fixed with for the li's, so I tried this:</p> <pre class="lang-css prettyprint-override"><code>.menu li { position: relative; } ul.submenu { position: absolute; width: 100%; } </code></pre> <p>But it is not - as I would expect - expanding to the 100% width of its parent (li) but rather gaining the width of the nearest specified element (in this case the div with width 960px I think, but it might also be larger).</p> <hr /> <p>My question is: Is it possible to expand the second-level ul-element to the width of its parent, the table-cell styled li without falling back to JavaScript?</p> <p>I am aware of the fact, that I'd have to write a Script for disabled browsers, like IE&lt;=7. Here is a running example: <a href="http://jsfiddle.net/hy73d/" rel="nofollow">http://jsfiddle.net/hy73d/</a></p> <p><hr /> Edit #1: It was brought to my attention, that this actually works in webkit-browsers and opera; so the real question would be, is there a solution for gecko?</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.
 

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