0

im trying to make a very simple menu here basically i want to hover over the link and a menu show up. but its not showing up! i nested 2 tags inside of each other and gave em ids. u can see the rest in code.

.navbar {
  width: 100%;
  height: 30px;
  overflow: no-display;
}

#headermenu {
  display: none;
}

#amenu:hover #headermenu {
  display: block;
}
<nav class="navbar">
  <ul id="Header">
    <li>
      <a id="amenu">aaaa
        <div id="headermenu">
          <ul>
            <li><a>menue yek</a></li>
          </ul>
        </div>
      </a>
    </li>
  </ul>
</nav>
Gerard
  • 15,418
  • 5
  • 30
  • 52

2 Answers2

1

You have to remove the submenu from the a tag, and put the "amenu" id on the li item, like so:

.navbar{
   width:100%;
   height:30px;
   overflow: no-display;
}
#headermenu{
   display:none;
}

#amenu:hover #headermenu{
   display:block;
}
<nav class="navbar">
  <ul id="Header">
    <li id="amenu">
      <a>aaaa</a>
      <div id="headermenu">
        <ul>
          <li><a>menue yek</a></li>
        </ul>
      </div>
    </li>
  </ul>
</nav>
  • To be honest I cannot really explain exactly why it wasn't working, all I know is that the tag behaves differently from a
  • tag, and trying to display a submenu from inside an tag just doesn't work, I don't exactly know why.
  • – Ioan-Radu Tanasescu Dec 05 '17 at 09:33