Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>UPDATED ANSWER 2</strong></p> <p>We still have nested <code>&lt;ul class="side_sub_nav"&gt;</code> inside the list item <code>&lt;li&gt;</code>. But this time around we are targeting the anchor tags <code>&lt;a&gt;</code> in the list items <code>&lt;li&gt;</code>. So all the styling that was being applied to the list items are now being applied to the anchor tags. I also added anchor tags to the second level list items which you did not have before.</p> <p>I think the main issue you were having is that your second level menus were siblings (adjacent) to the elements you were hovering at the top level. This made it hard to target.</p> <p>Here is an updated jsFiddle: <a href="http://jsfiddle.net/Sggsz/6/" rel="nofollow">http://jsfiddle.net/Sggsz/6/</a>, along with the HTML and CSS below.</p> <p><strong>HTML</strong> </p> <pre><code>&lt;ul class="side_nav"&gt; &lt;li class="li_sb "&gt; &lt;a href="index.php?p=subcategories_list&amp;amp;cat=1"&gt;Vie professionnelle&lt;/a&gt; &lt;ul class="side_sub_nav"&gt; &lt;li&gt;&lt;a href="#"&gt;Vie professionnelle - subc2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Vie professionnelle - subc1&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li class="li_sm "&gt; &lt;a href="index.php?p=subcategories_list&amp;amp;cat=4"&gt;Administration et droit&lt;/a&gt; &lt;ul class="side_sub_nav"&gt; &lt;li&gt;&lt;a href="#"&gt;Administration et droit - subc1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Administration et droit - subc2&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li class="li_sp "&gt; &lt;a href="index.php?p=subcategories_list&amp;amp;cat=5"&gt;Vie pratique&lt;/a&gt; &lt;ul class="side_sub_nav"&gt; &lt;li&gt;&lt;a href="#"&gt;Vie pratique - subc1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Vie pratique - subc2&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li class="li_sh "&gt; &lt;a href="index.php?p=subcategories_list&amp;amp;cat=6"&gt;Immobilier et logement&lt;/a&gt; &lt;ul class="side_sub_nav"&gt; &lt;li&gt;&lt;a href="#"&gt;Immobilier et logement - subc1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Immobilier et logement - subc2&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p><strong>CSS</strong> </p> <pre><code>.side_nav, .side_sub_nav { list-style: none; width: 250px; } .side_nav { margin-bottom: 37px; } .side_sub_nav { display: none; } .side_nav li:hover .side_sub_nav { display:block; } .side_nav a, .side_sub_nav a { height: 42px; line-height: 42px; border: 1px solid #dddddd; text-decoration: none; } .side_nav a { background-color: #f0f0f0; background-repeat: no-repeat; background-position: 8px center, 232px center; font-size: 16px; width: 205px; padding-left: 45px; display: block; color: #3f3f3f; } .side_sub_nav a { background-color: #008ec9; font-size: 12px; padding-left: 22px; color: white; } .side_sub_nav a:hover { color: red; } </code></pre> <p><strong>ANSWER 1</strong></p> <p>You should be nesting your sub menu in your list elements like so:</p> <p><strong>HTML</strong> </p> <pre><code>&lt;ul class="side_nav"&gt; &lt;li class="li_sb "&gt; &lt;a href="index.php?p=subcategories_list&amp;amp;cat=1"&gt;Vie professionnelle&lt;/a&gt; &lt;ul class="side_sub_nav"&gt; &lt;li&gt;Vie professionnelle - subc2&lt;/li&gt; &lt;li&gt;Vie professionnelle - subc1&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li class="li_sm "&gt; &lt;a href="index.php?p=subcategories_list&amp;amp;cat=4"&gt;Administration et droit&lt;/a&gt; &lt;ul class="side_sub_nav"&gt; &lt;li&gt;Administration et droit - subc1&lt;/li&gt; &lt;li&gt;Administration et droit - subc2&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p><strong>CSS</strong> </p> <pre><code>.side_sub_nav { display: none; } .side_nav li:hover .side_sub_nav { display: block; } </code></pre>
    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.
    1. 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