I'm creating a sb admin 2 like page where it has 2 navigations that looks like this:
And what I've done so far is this:
As you can see, the side navigation extends at the top bar. My code so far is this:
<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div class="navbar-fixed">
<!-- Dropdown Structure -->
<ul id="dropdown1" class="dropdown-content">
<li><a href="#!">User Profile</a></li>
<li><a href="#!">Settings</a></li>
<li class="divider"></li>
<li><a href="#!">Logout</a></li>
</ul>
<nav class="light-blue lighten-1" role="navigation">
<div class="nav-wrapper container">
<a href="#!" class="brand-logo">Point of Sale</a>
<ul class="right hide-on-med-and-down">
<!-- Dropdown Trigger -->
<li><a class="dropdown-button" href="#!" data-activates="dropdown1">Profile<i class="material-icons right">arrow_drop_down</i></a></li>
</ul>
</div>
</nav>
</div>
<ul id="slide-out" class="side-nav fixed">
<li><a href="#!">First Sidebar Link</a></li>
<li><a href="#!">Second Sidebar Link</a></li>
</ul>
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="js/materialize.min.js"></script>
<script>
(function($){
$(function(){
$('.button-collapse').sideNav();
}); // end of document ready
})(jQuery); // end of jQuery name space
</script>
</body>
</html>
What I am trying to achieve is this:
Is this possible?
As the Side Nav documentations says:
You have to offset your content by the width of the side menu. so do like this
<style type="text/css">
.wrapper {
padding-left: 300px;
}
</style>
and wrap your code in wrapper div
<div class="wrapper">
<div class="">
<!-- Dropdown Structure -->
<ul id="dropdown1" class="dropdown-content">
<li><a href="#!">User Profile</a></li>
<li><a href="#!">Settings</a></li>
<li class="divider"></li>
<li><a href="#!">Logout</a></li>
</ul>
<nav class="light-blue lighten-1" role="navigation">
<div class="nav-wrapper container">
<a href="#!" class="brand-logo">Point of Sale</a>
<ul class="right hide-on-med-and-down">
<!-- Dropdown Trigger -->
<li><a class="dropdown-button" href="#!" data-activates="dropdown1">Profile<i class="material-icons right">arrow_drop_down</i></a></li>
</ul>
</div>
</nav>
</div>
</div>
<ul id="slide-out" class="side-nav fixed">
<li><a href="#!">First Sidebar Link</a></li>
<li><a href="#!">Second Sidebar Link</a></li>
</ul>
here is my fix to avoid over lap with the top navbar, and to hide on small to med screens
add:
<ul class="sidenav sidenav-fixed invesible-top" id="mobile-nav">
also optional to make it show on top again on small screens:
<li class="hide-on-large-only">
style:
@media only screen and (min-width : 992px) {
.invesible-top {
top: 65px;
}
}
Sometime I ran into some problem when Nav was overflowing beyond the width of its wrapper (in my case, header tag) so I use this instead of what MaterializeCSS recommends:
Note: In sass though.
header, main, footer {
margin-left: 300px;
nav {
left: 300px;
right: 0;
width: auto;
}
@media only screen and (max-width : 992px) {
margin-left: 0;
nav {
left: 0;
right: 0;
width: auto;
}
}
}
You should try:
<style type="text/css">
.side-nav{
top: 65px;
width: 250px;
}
</style>
and wrap your code in header and aside:
<header>
<div class="navbar-fixed">
<!-- Dropdown Structure -->
<ul id="dropdown1" class="dropdown-content">
<li><a href="#!">User Profile</a></li>
<li><a href="#!">Settings</a></li>
<li class="divider"></li>
<li><a href="#!">Logout</a></li>
</ul>
<div class="nav-wrapper">
<nav class="light-blue lighten-1" role="navigation">
<div class="nav-wrapper container">
<a href="#!" class="brand-logo">Point of Sale</a>
<ul class="right hide-on-med-and-down">
<!-- Dropdown Trigger -->
<li><a class="dropdown-button" href="#!" data-activates="dropdown1">Profile<i class="material-icons right">arrow_drop_down</i></a></li>
</ul>
</div>
</nav>
</div>
</div>
</header>
<aside>
<ul id="slide-out" class="side-nav fixed">
<li><a href="#!">First Sidebar Link</a></li>
<li><a href="#!">Second Sidebar Link</a></li>
</ul>
</aside>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With