css dropdown menu inside unordered list (ul)

Jay Dee :

I wanted to ask you if there is any way I could insert a dropdown menu at Services inside ul, li tags? I know how to add dropdown menus where instead of using ul/li we use buttons but I wanted to know if there is any other way with ul/li since then I have to restructure the css... So you maybe understand me! I'll drop the code down so you can have a quick glance. Thank you very much!

<nav>
    <ul class="nav-links">
        <li><a class="nav-link" href="index.html" id="active">Home</a></li>
        <li><a class="nav-link" href="#">Services</a></li>
        <li><a class="nav-link" href="#">About</a></li>
        <li><a class="nav-link" href="#">Contact</a></li>
    </ul>
</nav>

Manjuboyz :

You can do something like this:

Source

  #nav {
  list-style: none inside;
  margin: 0;
  padding: 0;
  text-align: center;
}

#nav li {
  display: block;
  position: relative;
  float: left;
  background: #24af15;
  /* menu background color */
}

#nav li a {
  display: block;
  padding: 0;
  text-decoration: none;
  width: 200px;
  /* this is the width of the menu items */
  line-height: 35px;
  /* this is the hieght of the menu items */
  color: #ffffff;
  /* list item font color */
}

#nav li li a {
  font-size: 80%;
}


/* smaller font size for sub menu items */

#nav li:hover {
  background: #003f20;
}


/* highlights current hovered list item and the parent list items when hovering over sub menues */

#nav ul {
  position: absolute;
  padding: 0;
  left: 0;
  display: none;
  /* hides sublists */
}

#nav li:hover ul ul {
  display: none;
}


/* hides sub-sublists */

#nav li:hover ul {
  display: block;
}


/* shows sublist on hover */

#nav li li:hover ul {
  display: block;
  /* shows sub-sublist on hover */
  margin-left: 200px;
  /* this should be the same width as the parent list item */
  margin-top: -35px;
  /* aligns top of sub menu with top of list item */
<ul id="nav">
  <li><a href="#">Home</a></li>
  <li><a href="#">Services</a>
    <ul>
      <li><a href="#">Services-1</a></li>
      <li><a href="#">Services-2</a></li>
      <li><a href="#">SUB Services »</a>
        <ul>
          <li><a href="#">Sub Services 1</a>
            <li><a href="#">Sub Services 2</a>
        </ul>
        </li>
    </ul>
    </li>
    <li><a href="#">About</a></li>
</ul>

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=398848&siteId=1