title: Drop down menu using styled-components: How to properly use class selectors?
body: <p>Using styled components, I want to build a React component that will mimic the following code from <a href="https://www.w3schools.com/css/tryit.asp?filename=trycss_dropdown_navbar" rel="nofollow noreferrer">W3 Schools</a>:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #333;
  }
  
  li {
    float: left;
  }
  
  li a, .dropbtn {
    display: inline-block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
  }
  
  li a:hover, .dropdown:hover .dropbtn {
    background-color: red;
  }
  
  li.dropdown {
    display: inline-block;
  }
  
  .dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
  }
  
  .dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
  }
  
  .dropdown-content a:hover {background-color: #f1f1f1;}
  
  .dropdown:hover .dropdown-content {
    display: block;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt;
  
  &lt;ul&gt;
    &lt;li&gt;&lt;a href="#home"&gt;Home&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#news"&gt;News&lt;/a&gt;&lt;/li&gt;
    &lt;li class="dropdown"&gt;
      &lt;a href="javascript:void(0)" class="dropbtn"&gt;Dropdown&lt;/a&gt;
      &lt;div class="dropdown-content"&gt;
        &lt;a href="#"&gt;Link 1&lt;/a&gt;
        &lt;a href="#"&gt;Link 2&lt;/a&gt;
        &lt;a href="#"&gt;Link 3&lt;/a&gt;
      &lt;/div&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;h3&gt;Dropdown Menu inside a Navigation Bar&lt;/h3&gt;
  &lt;p&gt;Hover over the "Dropdown" link to see the dropdown menu.&lt;/p&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here is my React Component:</p>
  
  <pre><code>import React, { Component } from "react";
  import PropTypes from "prop-types";
  import styled, { ThemeProvider } from "styled-components";
  
  
  const StyledUl = styled.ul`
      list-style-type: none;
      margin: 0;
      overflow: hidden;
      background-color: #333;
      padding: 0px;
      background-color: lightblue;
      color: black;
      font-weight: bold;
  `;
  
  const StyledLi = styled.li`
      float: left;
      height: 100%;
      padding: 10px;
      &amp;:hover {
          background-color: red;
      }
  `;
  
  const DropDownContent = styled.div`
      display: none;
      position: absolute;
      min-width: 160px;
      z-index: 1;
  `;
  
  const DropDownLi = styled(StyledLi)`
      display: inline-block;
      &amp;:hover ${DropDownContent} {
          display: block;
      }
  `;
  
  const StyledA = styled.a`
      display: inline-block;
      text-align: center;
      text-decoration: none;
  `;
  
  const SubA = styled(StyledA)`
      text-decoration: none;
      display: block;
      text-align: left;
      background-color: lightblue;
      padding: 10px;
  `;
  
  class Menu extends Component {
      handleClick = action =&gt; {
          if (!action) return;
  
          if (this.props.onClick) this.props.onClick(action);
      };
  
      render = () =&gt; {
          return (
              &lt;StyledUl&gt;
                  &lt;StyledLi&gt;
                      &lt;StyledA onClick={() =&gt; this.handleClick("Home")}&gt;
                          Home
                      &lt;/StyledA&gt;
                  &lt;/StyledLi&gt;
                  &lt;StyledLi&gt;
                      &lt;StyledA onClick={() =&gt; this.handleClick("News")}&gt;
                          Home
                      &lt;/StyledA&gt;
                  &lt;/StyledLi&gt;
                  &lt;DropDownLi&gt;
                      &lt;StyledA onClick={() =&gt; this.handleClick("DropDown")}&gt;
                          DropDown
                      &lt;/StyledA&gt;
                      &lt;DropDownContent&gt;
                          {" "}
                          &lt;SubA onClick={() =&gt; this.handleClick("Link1")}&gt;
                              Link 1
                          &lt;/SubA&gt;
                          &lt;SubA onClick={() =&gt; this.handleClick("Link2")}&gt;
                              Link 2
                          &lt;/SubA&gt;
                          &lt;SubA onClick={() =&gt; this.handleClick("Link3")}&gt;
                              Link 3
                          &lt;/SubA&gt;
                      &lt;/DropDownContent&gt;
                  &lt;/DropDownLi&gt;
              &lt;/StyledUl&gt;
          );
      };
  }
  
  export default Menu;
  </code></pre>
  
  <p>The result is not the same, basically because I'm not sure how to work with selectors inside <code>styled-component</code>. </p>
  
  <p>How can I fix my ReactJs component <code>Menu</code> code to behave exactly like the W3 example?</p>