Create A Multi-Level Drop Down Menu with Pure CSS

Category: CSS & CSS3 , Menu & Navigation | June 21, 2014
Views Total: 12,610
Official Page: Go to website
Last Update: June 21, 2014
License: Unknown


Create A Multi-Level Drop Down Menu with Pure CSS


A flat designed multi-level drop down menu built with plain Html markup and pure CSS. Created by twodogstar.

How to use it:

Code your multi-level dropdown menu using nested Html lists as follows.

<ul class="main-navigation">
  <li><a href="#">Home</a></li>
  <li><a href="#">Front End Design</a>
      <li><a href="#">HTML</a></li>
      <li><a href="#">CSS</a>
          <li><a href="#">Resets</a></li>
          <li><a href="#">Grids</a></li>
          <li><a href="#">Frameworks</a></li>
      <li><a href="#">JavaScript</a>
          <li><a href="#">Ajax</a></li>
          <li><a href="#">jQuery</a></li>
  <li><a href="#">WordPress Development</a>
      <li><a href="#">Themes</a></li>
      <li><a href="#">Plugins</a></li>
      <li><a href="#">Custom Post Types</a>
          <li><a href="#">Portfolios</a></li>
          <li><a href="#">Testimonials</a></li>
      <li><a href="#">Options</a></li>
  <li><a href="#">About Us</a></li>

Set the parent <li>’s CSS position property to ‘relative’.

ul {
  list-style: none;
  padding: 0;
  margin: 0;
  background: #1bc2a2;

ul li {
  display: block;
  position: relative;
  float: left;
  background: #1bc2a2;

The CSS to hide the sub menus.

li ul { display: none; }

ul li a {
  display: block;
  padding: 1em;
  text-decoration: none;
  white-space: nowrap;
  color: #fff;

ul li a:hover { background: #2c3e50; }

Displays the dropdown menu on hover.

li:hover > ul {
  display: block;
  position: absolute;

li:hover li { float: none; }

li:hover a { background: #1bc2a2; }

li:hover li a:hover { background: #2c3e50; }

.main-navigation li ul li { border-top: 0; }

Displays second level dropdown menus to the right of the first level dropdown menu.

ul ul ul {
  left: 100%;
  top: 0;

Simple clearfix.

ul:after {
  content: " "; /* 1 */
  display: table; /* 2 */

ul:after { clear: both; }
  • greenland

    thanks bro

  • shivam

    its very poor working please don’t share .because mobil version its not good .

  • Mario Lukačić

    Great menu thanks for sharing.
    @disqus_MY4GFFfVmy:disqus it’s not made for mobile, and its so easy to adapt it to mobile so don’t be lazy and copy -> paste

  • Eric S

    why the fucking line numbers that make this impossible to copy/paste ?!?!

    • Seif Sayed

      click on the raw button to view the code without line numbers

    • Ahmet Altın

      god damnn eric u are so right buddy !

  • Alok Joshi

    Thank you for a great tutorial.