Search code examples
htmlcssdrop-down-menusubmenu

Submenu doesn't get displayed


I'm trying to make sub-menus for my menu, but something just isn't right and doesn't pop out like I want.

<div class="navbox">
<ul class="nav">
<li><a href="#">Program</a></li>
<li><ul>
<li><a href="#">Teknik</a></li>
<li><a href="#">Naturvetenskap</a></li>
<li><a href="#">El</a></li>
</ul></li>
</ul></div>

* { margin:0;
padding:0;
}

html {height: 100%;}

body{
    position: relative;
    height: 100%;
    background: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#fff));

}

.navbox {
    position: relative;
    float: left;
}


ul.nav {
    list-style: none;
    display: block;
    width: 200px;
    position: relative;
    top: 100px;
    left: 100px;
    padding: 60px 0 60px 0;
    background: url(shad2.png) no-repeat;
    -webkit-background-size: 50% 100%;
    display: inline-table;
}




li {
    margin: 5px 0 0 0;
}

ul.nav li a  {
    -webkit-transition: all 0.3s ease-out;
    background: #cbcbcb url(border.png) no-repeat;
    color: #174867;
    padding: 7px 15px 7px 15px;
    -webkit-border-top-right-radius: 10px;
    -webkit-border-bottom-right-radius: 10px;
    width: 100px;
    display: block;
    text-decoration: none;
    -webkit-box-shadow: 2px 2px 4px #888;
}

 ul.nav li :hover {
 background: #ebebeb url(border.png) no-repeat;
 color: #67a5cd;
 padding: 7px 15px 7px 30px;
 }

The problem with the code is that I want to get the link "Program" to display the submenus under, "Teknik" "Naturvetenskap" "El" but I just can't get them to pop out under. I can't get them to pop out at all, and that's all I need, I'll have to deal with design later.


Solution

  • Made it into a codepen for you - http://codepen.io/anon/pen/pxfKE - and tried to answer what I think you were looking for. It should be pretty self explanatory, but let me know if you need help understanding it :)