SmashingJummy
SmashingJummy

Reputation: 448

Make dropdown menu from existing css menu

ul li ul.dropdown{
	min-width: 125px;
    background: #f2f2f2;
    display: none;
    position: absolute;
    z-index: 999;
    left: 0;
}
ul li:hover ul.dropdown{
    display: block;
}
ul li ul.dropdown li{
	display: block;
    }
<div class="navigation">
 


	<ul>
	<li><a href = 'index.html'>Home</a></li>
	<li><a href = 'media.html'>Media Design</a></li>
	<li><a href = 'innovatie.html'>Innovatieroutes</a></li>
	<li><a href = 'info.html'>Informatie</a></li>
	        <ul class="dropdown">
            <li><a href="#">Open dagen</a></li>
            <li><a href="#">Beroepen</a></li>
            <li><a href="#">Studie</a></li>
			</ul>
	<li><a href = 'contact.html'>Contact</a></li>
</ul>

I'm trying to make a CSS menu with a dropdown, but somehow I am not able to let to menu drop down when I hover the mouse over the tab "Informatie", the sub menus will just display after "Informatie". Maybe some of you guys are able to help me with my menu.

Upvotes: 0

Views: 277

Answers (2)

Xahed Kamal
Xahed Kamal

Reputation: 2223

Fixed your code

ul li ul.dropdown{
	min-width: 125px;
    background: #f2f2f2;
    display: none;
    position: absolute;
    z-index: 999;
    left: 0;
}
ul li:hover ul.dropdown{
    display: block;
}
ul li ul.dropdown li{
	display: block;
    }
<div class="navigation">
 


	<ul>
	<li><a href = 'index.html'>Home</a></li>
	<li><a href = 'media.html'>Media Design</a></li>
	<li><a href = 'innovatie.html'>Innovatieroutes</a>
	<li><a href = 'info.html'>Informatie</a>
	        <ul class="dropdown">
            <li><a href="#">Open dagen</a></li>
            <li><a href="#">Beroepen</a></li>
            <li><a href="#">Studie</a></li>
			</ul>
     </li>
	<li><a href = 'contact.html'>Contact</a></li>
</ul>

Your mistake was, you wrote the ul outside li's closing tag </li>. You've to put ul's code right after ending of a tag's closing tag </a>

Upvotes: 1

Jacob Parker
Jacob Parker

Reputation: 111

You need to put the ul inside the li.

Upvotes: 1

Related Questions