Hovering Dropdown Menus

I was getting very concerned about how to achieve the dropdown menu I wanted for the navigation area. I couldn’t find a solution in any of the textbooks I’ve been using.

I did a search on menus and navigation and it took some time, but I finally found a workable solution on http://www.alistapart.com/articles/horizdropdowns/

It was a surprisingly easy process; where the on-hover menu is nested inside a list item (the link that is being hovered over).

The HTML code looks like this:

<div id=”menu”>
<ul>
<li>profile
<ul>
<li><a href=”awards.html”>awards</a></li>
<li><a href=”exhibitions.html”>exhibitions</a></li>
<li><a href=”publications.html”>publications</a></li>
</ul>
</li>
<li>projects
<ul>
<li><a href=”projects/slideshow.html”>project slideshow</a></li>
<li>furniture…</li>
<li><a href=”projects/2009.html”>…2009</a></li>
<li><a href=”projects/2008.html”>…2008</a></li>
<li><a href=”projects/2007.html”>…2007</a></li>
<li><a href=”projects/interiors.html”>interior design</a></li>
</ul>
</li>
<li><a href=”contact.html”>contact</a></li>
</ul>
</div>

Using CSS, the unordered list which is nested inside a list item is positioned absolutely, and has no display until the list item is hovered over.

The following CSS code was taken from the above site with some minor modifications.

li ul {
position: absolute;
left: 149px;
top: 0;
display: none;
}
ul li a {
display: block;
text-decoration: none;
background: #fff;
padding: 1px 10px 5px 0px;
border: none;
}
li:hover ul {
display: block;
}

Advertisement

2 Responses to “Hovering Dropdown Menus”

  1. RedDesertRoz Says:

    Hi Vanessa

    I am tackling the same issue for a horizontal navigation. I have adapted the suckerfish dropdown from http://www.alistapart.com/articles/dropdowns/ with a couple of problems. The first is that I had styled my links to look like buttons, but as some of the li don’t contain links now – they contain an ul instead – this method adds colour and padding and so on to the li rather than the a tags. The problem with this is that the button appearance is a bit lost and you now must click on the link text rather than a button area. The second problem is getting my drop down items to display underneath each other. Evidently some of the other css I have used is interfering here as they are displaying haphazardly! Glad you’ve solved your navigation problems – the navigation has been one of the most difficult aspects of my site to be honest, when I was expecting it to be easy!

  2. JavaScript drop down menu « Annamanly's Blog Says:

    [...] to fellow student Vaneesa’a post on drop down menu’s, I looked at her script and then tried to translate what all the codling [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.