We help IT Professionals succeed at work.
Get Started

How do I get my dropdown navigation menu to work using CSS?

shampouya
shampouya asked
on
233 Views
Last Modified: 2012-04-19
I have a simple menu in my navigation div at the top of my website, consisting of a <ul> with several <li>s that float left. Then I have a nested set of <ul>s and <li>s that are hidden, that I want to appear when the user hovers over the first set of <li>s. My CSS code below isn't working. It's causing all the buttons and sub-buttons to float left, and nothing is ever hidden. Any idea what is wrong below?


.menuSectionDiv li{float:left; position:relative;}
.menuSectionDiv li ul{position:absolute; display:none; top:35px; left:0;}
.menuSectionDiv li ul li{float: none;}
.menuSectionDiv li:hover ul{display:block;}

<div class="menuSectionDiv">
		<ul>
			<li><a href="#"><span id="homeButton">Home</span></a></li>
			<li><a href="#"><span id="servicesButton">Services</span></a></li>	
				<ul>
					<li><a href="#"><span id="">Item1</span></a></li>
					<li><a href="#"><span id="">Item2</span></a></li>	
					<li><a href="#"><span id="">Item3</span></a></li>
					<li><a href="#"><span id="">Item4</span></a></li>
				</ul>			
			<li><a href="#"><span id="aboutButton">About</span></a></li>
				<ul>
					<li><a href="#"><span id="">Item1</span></a></li>
					<li><a href="#"><span id="">Item2</span></a></li>	
					<li><a href="#"><span id="">Item3</span></a></li>
					<li><a href="#"><span id="">Item4</span></a></li>
				</ul>	
			<li><a href="#"><span id="contactButton">Contact</span></a></li>
				<ul>
					<li><a href="#"><span id="">Item1</span></a></li>
					<li><a href="#"><span id="">Item2</span></a></li>	
					<li><a href="#"><span id="">Item3</span></a></li>
					<li><a href="#"><span id="">Item4</span></a></li>
				</ul>				
		</ul>
</div> 

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE