Multi-Level Responsive Dropdown Menu using css

Today we are going to see how to create multilevel responsive dropdown menu using pure css and html. We already seen how to create responsive one step dropdown menu and responsive menu without any dropdown menu. Now we are going to see how to create multilevel dropdown menu with the help of css.

Most of the websites wants this type of multilevel dropdown menu because lot of navigation having the lot of sub categories so we need this types of multi-level drop down menu to solve this issue. The below example shows responsive dropdown menu. You can view the live demo using the demo button and also download the full code here.

In this navigation bar is displayed as a accordion type menu in Mobile devices or small devices. The dropdown menu consist small down arrow button to indicate the dropdown menu. I hope this is very useful.


Html code for Multilevel responsive dropdown Menu

<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Multilevel Responsive dropdown Menu using css</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<menu>
<label for="drop" class="toggle" style="background-color: #BC7A1E;">Menu</label>
<input type="checkbox" id="drop" />
<ul class="menu">
<li><a href="#">My Bid</a></li>
<li>
<label for="drop-1" class="toggle">Dashboard &#9660;</label>
<a href="#">Dashboard</a>
<input type="checkbox" id="drop-1"/>
<ul>
<li><a href="#">Dashboard1</a></li>
<li><a href="#">Dashboard2</a></li>
<li><a href="#">Dashboard3</a></li>
</ul>
</li>
<li>
<label for="drop-2" class="toggle">Identity &#9660;</label>
<a href="#">Identity</a>
<input type="checkbox" id="drop-2"/>
<ul>
<li><a href="#">Identity1</a></li>
<li><a href="#">Identity2</a></li>
<li>
<label for="drop-3" class="toggle">Identity3 &#9660; </label>
<a href="#">Identity3</a>      
<input type="checkbox" id="drop-3"/>
<ul>
<li><a href="#">Identity3.1</a></li>
<li><a href="#">Identity3.2</a></li>
<li><a href="#">Identity3.3</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#">Change Password</a></li>
<li><a href="#">Invalid Bid Report</a></li>
<li><a href="#">Rft Upload</a></li>
<li><a href="#">Logout</a></li>
</ul>
</menu>
<h1>Multilevel Responsive Menu using css</h1>
<p> A simple Multilevel dropdown navigation menu made with CSS Only. </p>
<a href="http://www.sanwebcorner.com">Sanwebcorner.com</a>
</body>
</html>


Css for Multilevel dropdown Navigationbar:

.toggle,
[id^=drop] {
display: none;
}

menu {
margin:0;
padding: 0;
background-color: #bc1e2d;
}

menu:after {
content:"";
display:table;
clear:both;
}

menu ul {
float: right;
padding:0;
margin:0;
list-style: none;
position: relative;
}

menu ul li {
margin: 0px;
display:inline-block;
float: left;
}

menu a {
display:block;
padding:14px 20px;
color:#fff;
font-size:17px;
text-decoration:none;
}


menu ul li ul li:hover { background-color:#bb3946; }

menu a:hover {
background-color:none;
color:#fff;
}

menu ul ul {
display: none;
position: absolute;
top: 48px;

}



menu ul li:hover > ul {
display:inherit;
}

menu ul ul li {
width:170px;
float:none;
display:list-item;
position: relative;
border-bottom: 1px solid #EB8E96;
background-color: #B52F3C;
}

menu ul ul ul li {
position: relative;
top:-60px;
left:170px;
background-color: #B52F3C;
}


li > a:after { content:  ' ▼'; font-size:11px;}
li > a:only-child:after { content: ''; }



@media all and (max-width : 768px) {

menu {
margin: 0;
}

.toggle + a,
.menu {
display: none;
}

.toggle {
display: block;
background-color: #86151F;
padding:14px 20px;
color:#FFF;
font-size:17px;
text-decoration:none;
border:none;
}

.toggle:hover {
background-color: #DC4E5B;
}

[id^=drop]:checked + ul {
display: block;
}

menu ul li {
display: block;
width: 100%;
}

menu ul ul .toggle,
menu ul ul a {
padding: 0 40px;
}

menu ul ul ul a {
padding: 0 80px;
}

menu a:hover,
  menu ul ul ul a {
background-color: #C34854;
}

menu ul li ul li .toggle,
menu ul ul a,
  menu ul ul ul a{
padding:14px 20px;
color:#FFF;
font-size:17px;
}


menu ul li ul li .toggle,
menu ul ul a {
background-color: #BF3441;
}

menu ul ul {
float: none;
position:static;
color: #ffffff;
}

menu ul ul li:hover > ul,
menu ul li:hover > ul {
display: none;
}


menu ul ul li {
display: block;
width: 100%;
}

menu ul ul ul li {
position: static;

}

}

@media all and (max-width : 330px) {

menu ul li {
display:block;
width: 94%;
}

}

Post a Comment

0 Comments