- This the barebones code for MetisMenu.
- There are only 2 dependencies from Bower. Installing these 2 will get you JQuery installed as well.
bower install bootstrap
bower install metismenu
- The main codes in
index.html
.
<!DOCTYPE html>
<html>
<head>
<link
href="bootstrap.min.css"
rel="stylesheet"
>
<link
href="metis.css"
rel="stylesheet"
>
<link
href="metisMenu.min.css"
rel="stylesheet"
>
<title>{% if page_title %}{{page_title}} - {% endif %}{{site_name}}</title>
</head>
<body>
<aside class="sidebar">
<nav class="sidebar-nav">
<ul
class="metismenu"
id="metismenu"
>
<li>
<a aria-expanded="false">Test 1</a>
<ul>
<li><a>Test 1.1</a></li>
<li><a>Test 1.2</a></li>
<li><a>Test 1.3</a></li>
<li><a>Test 1.4</a></li>
<li><a>Test 1.5</a></li>
</ul>
</li>
<li><a>Test 2</a></li>
<li><a>Test 3</a></li>
<li><a>Test 4</a></li>
<li><a>Test 5</a></li>
</ul>
</nav>
</aside>
<script src="jquery.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="metisMenu.min.js"></script>
<script>
$("#metismenu").metisMenu();
</script>
</body>
</html>
- Here is the basic MetisMenu CSS I used for all of my project.
.sidebar-nav a,
.sidebar-nav a:active,
.sidebar-nav a:focus,
.sidebar-nav a:hover{
outline: none;
}
.sidebar-nav ul a,
.sidebar-nav ul li{
display: block;
}
.sidebar-nav ul a:hover{
background: rgba(255, 255, 255, 0.2);
text-decoration: none;
}
.sidebar-nav ul a{
background: #45283C;
border-top: 1px solid rgba(0, 0, 0, 0.3);
box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.05) inset;
color: #AAA;
padding: 10px 20px;
text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.5);
}
.sidebar-nav ul ul a:hover{
background: rgba(255, 255, 255, 0.2);
text-decoration: none;
}
.sidebar-nav ul ul a{
background: #663931;
padding: 10px 30px;
}
.sidebar-nav ul ul ul a:hover{
background: rgba(255, 255, 255, 0.2);
text-decoration: none;
}
.sidebar-nav ul ul ul a{
background: #8F563B;
padding: 10px 40px;
}
.sidebar-nav ul{
list-style: none;
margin: 0;
padding: 0;
}
.sidebar-nav{
background-image: -webkit-linear-gradient(left, color-stop(#333333 10px), color-stop(#222222 10px));
background-image: linear-gradient(to right, #333333 10px, #222222 10px);
background-repeat: repeat-x;
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#ff333333', endColorstr='#ff222222', GradientType=1);
}
.sidebar-nav-item{
padding-left: 5px;
}
.sidebar-nav-icon{
padding-right: 5px;
}
.sidebar{
background: #333;
display: block;
float: left;
width: 100%;
}