Skip to content Skip to sidebar Skip to footer

How Do I Add A Horizontal Submenu? Can't Figure It Out, Added Html And Css

Hey I would like to have a dropdown sub- menu in the same style, I know it's simple but I'm still new to making websites and I can't figure it out by myself. here's my HTML

Solution 1:

You closed the li that will hold the submenu ul too early.

Try working with this:

<nav><ul><li><ahref="./index.html"><spanclass ="s2">Startpagina</span></a></li><li><ahref="./aanwinsten.html">Aanwinsten</a></li><li><ahref="./catalogus.html">Catalogus</a><ulclass="sub"><li><ahref="#">Pages</a></li><li><ahref="#">Archives</a></li><li><ahref="#">New Posts</a></li></ul></li> **<! - See the difference?-->**
            <li><ahref="./uitlening.html">Uitlening</a></li><li><ahref="./reservatie.html">Reservatie</a></li><li><ahref="./suggestie.html">Suggestie</a></li><li><ahref="./contact.html">Contact</a></li></ul></nav>

JSFiddle

Solution 2:

The problem lies here:

<li><ahref="./catalogus.html">Catalogus</a></li><ulclass="sub"><li><ahref="#">Pages</a></li><li><ahref="#">Archives</a></li><li><ahref="#">New Posts</a></li></ul><li><ahref="./uitlening.html">Uitlening</a></li>

You need to keep the <ul> inside the previous <li>. So make it this way:

<li><ahref="./catalogus.html">Catalogus</a><ulclass="sub"><li><ahref="#">Pages</a></li><li><ahref="#">Archives</a></li><li><ahref="#">New Posts</a></li></ul></li><li><ahref="./uitlening.html">Uitlening</a></li>

And now you can give the styling by positioning the <UL> tag in such a way that when you hover your mouse over the LI it shows up.

li.dropul {display: none; position: absolute;}
li.drop {position: relative}
li.drop:hoverul {display: block; left: auto; top: auto;}

Post a Comment for "How Do I Add A Horizontal Submenu? Can't Figure It Out, Added Html And Css"