- W3.CSS - Home
- W3.CSS - Overview
- W3.CSS - Environment Setup
- W3.CSS - Containers
- W3.CSS - Code Coloring
- W3.CSS - Cards
- W3.CSS - Responsive Design
- W3.CSS - Grids
- W3.CSS - Forms
- W3.CSS - Buttons
- W3.CSS - Tooltips
- W3.CSS - Modal Dialog
- W3.CSS - Tables
- W3.CSS - Lists
- W3.CSS - Images
- W3.CSS - Icons
- W3.CSS - Colors
- W3.CSS - Navigation
- W3.CSS - Utilities
- W3.CSS Useful Resources
- W3.CSS - Quick Guide
- W3.CSS - Useful Resources
- W3.CSS - Discussion
W3.CSS - Navigation
W3.CSS has several special classes to display a navigation bar or a menu on a website quickly.
| Sr. No. | Class Name & Description |
|---|---|
| 1 |
w3-topnav Styles a list as a horizontal menu/navigation bar. |
| 2 |
w3-sidenav Styles a list as a vertical menu/navigation bar. |
Example
w3css_navigation.htm
<html>
<head>
<title>The W3.CSS Navigation</title>
<meta name = "viewport" content = "width=device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://www.w3schools.com/lib/w3.css">
<link rel = "stylesheet" href = "http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
<link rel = "stylesheet" href = "https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body class = "w3-container">
<h2>Navigation Demo</h2>
<hr/>
<h3>Horizontal top navigation bar</h3>
<nav class = "w3-topnav w3-red">
<a href="#">Home</a>
<a href="#">Overview</a>
<a href="#">Environment</a>
<a href="#">Containers</a>
<a href="#">Grids</a>
</nav>
<h3>Using font awesome icons</h3>
<nav class = "w3-topnav w3-red">
<a href="#"><i class="fa fa-home"></i></a>
<a href="#">Overview</a>
<a href="#">Environment</a>
<a href="#">Containers</a>
<a href="#">Grids</a>
</nav>
<h3>Using material icons</h3>
<nav class = "w3-topnav w3-red">
<a href="#"><i class="material-icons">home</i></a>
<a href="#">Overview</a>
<a href="#">Environment</a>
<a href="#">Containers</a>
<a href="#">Grids</a>
</nav>
<h3>Using Side Navigation</h3>
<nav class = "w3-sidenav w3-red w3-card-2" style="width:25%">
<a href="#">Home</a>
<a href="#">Overview</a>
<a href="#">Environment</a>
<a href="#">Containers</a>
<a href="#">Grids</a>
</nav>
</body>
</html>
Result
Verify the result.
Advertisements