Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can get the effect that you want with a slight change in our HTML:</p> <pre><code>&lt;div class="container"&gt; &lt;ul id="topnav"&gt; &lt;li &gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;About&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Services&lt;/a&gt; &lt;div class="wrapper"&gt; &lt;div class="sec-nav"&gt; &lt;a href="#"&gt;What We Do&lt;/a&gt; &lt;a href="#"&gt;Our Process&lt;/a&gt; &lt;a href="#"&gt;Testimonials&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Portfolio&lt;/a&gt; &lt;div class="wrapper"&gt; &lt;div class="sec-nav"&gt; &lt;a href="#"&gt;Web Design&lt;/a&gt; &lt;a href="#"&gt;Analytics&lt;/a&gt; | &lt;a href="#"&gt;Database Design&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Contact&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>Just add a containing block <code>div.wrapper</code> around the block that contains the links.</p> <p>Adjust the CSS as follows:</p> <pre><code>ul#topnav li div.wrapper { padding-top: 40px; /* controls the gap between the menus */ position: absolute; left: 0; top: 33px; /* Add just enough height to clear the text links in top nav */ display: none; text-align:Center; width: 100%; color: #fff; -moz-border-radius: 0 0 5px 5px; -webkit-border-radius: 0 0 5px 5px; } ul#topnav li:hover div.wrapper { display: block; background-color: yellow; /* to show the spacing created by the wrapper */ } ul#topnav li div.sec-nav { background: #558ED5; } ul#topnav li div.sec-nav a { display: inline-block; } ul#topnav li a:hover {text-decoration: underline;} </code></pre> <p>You can see the working demo at: <a href="http://jsfiddle.net/audetwebdesign/cjTym" rel="nofollow">http://jsfiddle.net/audetwebdesign/cjTym</a></p> <p><strong>How This Works</strong></p> <p>Basically, adjust <code>top</code> for <code>div.wrapper</code> so that it overlaps the top navigation by a pixel or two. That way, when you don't lose focus when you move the mouse off the top navigation block.</p> <p>Add some top padding in <code>div.wrapper</code> to create the white (yellow) space between the two menus.</p> <p>Finally, apply the background color to the <code>.sec-nav</code> block that wraps your links.</p> <p>Everything else is the same so you should be all set.</p> <p><strong>Aside</strong></p> <p>I used <code>&lt;div&gt;</code> instead of <code>&lt;span&gt;</code> to wrap the links and so on. Alternatively, you could use a span element if you change the display type to block.</p>
 

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