Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are many ways to go ahead about this. </p> <p>I usually hide the sub menu <code>ul</code>s with <code>display: none</code> and take them out of the content flow with <code>position: absolute</code>. Give the <code>li</code> containing the sub menu <code>position: relative</code> so that the sub menus are relative to their direct parents, then position the sub menus however you please using the <code>top</code>, <code>right</code>, <code>bottom</code> and <code>left</code> properties. Finally, change the sub menu to <code>display: block</code> through a <code>:hover</code> or whatever.</p> <p><strong>Here's a bare-bones example of this:</strong></p> <p>Markup:</p> <pre><code>&lt;nav&gt; &lt;ul&gt; &lt;li&gt;&lt;a&gt;Link&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a&gt;Sub link&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;Sub link&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;Sub link&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; </code></pre> <p>CSS:</p> <pre><code>nav li { position: relative; } nav li &gt; ul { position: absolute; top: 100%; display: none; } nav li:hover &gt; ul { display: block; } </code></pre> <p><a href="http://codepen.io/Mest/pen/Akeus" rel="nofollow">Here's a pen with this example</a>. It looks like crap but you get the drill.</p> <p>You can just keep nesting more sub-menus, but you'll probably want to use different positioning for second-and-lower-levels of sub menus.</p> <p>However, please note that mobile browsers don't really support <code>:hover</code>. At least they don't treat it the same. You shouldn't make your sub menus accessible only on <code>:hover</code>. Consider adding some sort of class name toggle on click with javascript instead.</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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