Navbar
Materialize is a modern responsive CSS framework based on Material Design by Google.
Right Aligned Links
To right align your navbar links, just add a right
class to your
that contains them.
Left Aligned Links
To left align your navbar links, just add a left
class to your
that contains them.
Centering the logo
The logo will center itself on medium and down screens, but if you want the logo to always be centered, add the center
class to
your
. You will have to make sure yourself that links do not overlap if you use this.
Active Items
Add active class to your li tags to denote the current page.
Icon Links
You can add icons into links. For icon only links you don't need any additional class. Just pop the i
tag in and it will work.
For adding an icon to a text link you need to add either a left
or right
class to the icon
depending on where you want the icon to be.
Search Bar
You can add a search form in the navbar.
Mobile Collapse Button
When your nav bar is resized, you will see that the links on the right turn into a hamburger icon menu. Take a look at the example
below to get this functionality. Add the entire sidenav-trigger
line to your nav
.
Initialization
After including the sidenav-trigger line into your navbar, all you have to do now initialize the plugin. This example below assumes you have not modified the classes in the above example. In the case that you have, just change the selector in the line below to match it.
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.sidenav');
var instances = M.Sidenav.init(elems, options);
});