How to create: Navigation bar with icons
- Previous Page Split Navigation
- Next Page Search Menu
Learn how to create a responsive navigation bar with icons using CSS.
Navigation bar with icons
Create a responsive navigation bar with icons
Step 1 - Add HTML:
Load an icon library <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <div class="navbar"> <a class="active" href="#"><i class="fa fa-fw fa-home"></i> Home</a> <a href="#"><i class="fa fa-fw fa-search"></i> Search</a> <a href="#"><i class="fa fa-fw fa-envelope"></i> Contact</a> <a href="#"><i class="fa fa-fw fa-user"></i> Login</a> </div>
Second step - Add CSS:
/* Set the style of the navbar */ .navbar { width: 100%; background-color: #555; overflow: auto; } /* Navbar link style */ .navbar a { float: left; text-align: center; padding: 12px; color: white; text-decoration: none; font-size: 17px; } /* Navbar link style on hover */ .navbar a:hover { background-color: #000; } /* Current/active navbar link */ .active { background-color: #04AA6D; } /* Add responsiveness - on screens less than 500 pixels, the navbar will be displayed vertically automatically instead of horizontally */ @media screen and (max-width: 500px) { .navbar a { float: none; display: block; } }
Related Pages
Tutorial:CSS Navigation Bar
Tutorial:How to Create Icon Navigation Bar
- Previous Page Split Navigation
- Next Page Search Menu