title: CSS hover in a nav bar
body: <p>I have tried to make a nav bar using the ul li and disabling the text formatting in CSS. The code works almost fine, as I have made also a small fade-in animation for the buttons. The problem appears if I have a dropdown menu in my nav bar. Hovering my mouse over the li which has dropdown in it also causes the things in the dropdown to be animated.</p>
  
  <p>I know there may be some selectors you can use to make it not do so, but so far I haven't got it to work. What would be the right thing to do?</p>
  
  <p>Here's the HTML:</p>
  
  <pre><code>&lt;nav&gt;
      &lt;ul&gt;
  
          &lt;a href="index.html"&gt;&lt;li id="left"&gt;Home&lt;/li&gt;&lt;/a&gt;
          &lt;a href="#"&gt;&lt;li&gt;Menu 1&lt;/li&gt;&lt;/a&gt;
  
          &lt;li&gt;&lt;span&gt;Dropdown&lt;/span&gt;
              &lt;ul&gt;
                  &lt;a href="#"&gt;&lt;li&gt;Dropdown menu 1&lt;/li&gt;&lt;/a&gt;
                  &lt;a href="#"&gt;&lt;li&gt;Dropdown menu 2&lt;/li&gt;&lt;/a&gt;
              &lt;/ul&gt;
          &lt;/li&gt;
  
          &lt;a href="#"&gt;&lt;li&gt;Menu 3&lt;/li&gt;&lt;/a&gt;
          &lt;a href="#"&gt;&lt;li id="right"&gt;Contact me&lt;/li&gt;&lt;/a&gt;
  
      &lt;/ul&gt;
  
  &lt;/nav&gt;
  </code></pre>
  
  <p>Here's the CSS:</p>
  
  <pre><code>nav{
    display: inline;
    float: left;
    background-color: #d48041;
    box-shadow: 0 1vh 2vh -0.5vh #F2B57B inset;
    width:90%;
    padding-left:10%;
    height:5%;
    font-weight: bold;
  }
  
  nav ul{
    list-style: none;
    margin:0;
    padding:0;
    display: inline;
  }
  
  nav ul a{
    text-decoration: none;
    color: black;
    font-size: 1.5vh;
  }
  
  nav ul a li{
    display:inline-block;
    float:left;
    text-align: center;
    height: 5vh;
    line-height: 5vh;
    width:10%;
    margin:0;
    box-sizing: border-box;
  }
  
  nav ul li ul{
    display:none;
  }
  
  nav ul li:hover ul{
    display:block;
    position: absolute;
    z-index: 1;
    width: 91%;
    margin-left: -0.1vw;
  }
  
  nav ul li ul li{
    background-color: #FFA968;
    border: solid 0.04vw black;
  }
  
  nav ul a li:not(.noborder), nav ul li {
    border-right: solid 0.04vw black;
  }
  
  #left {
    border-left: solid 0.04vw black;
  }
  
  #right {
    float: right;
    width: 20%;
    margin-right:11.1%;
    border-left: solid 0.04vw black;
  }
  
  nav ul a:hover{
    animation-name: text_fadein;
    animation-duration: 0.3s;
    animation-fill-mode: forwards;
  }
  
  nav ul li:hover span{
    cursor: default;
  }
  
  nav ul a:hover li{
    animation-name: menu_fadein;
    animation-duration: 0.3s;
    animation-fill-mode: forwards;
  }
  </code></pre>