Web Styles

Navigation Patterns

Navbar, sidebar, breadcrumb, tabs, and responsive navigation.

Advertisement

Navigation Patterns

Navbar, sidebar, breadcrumb, tabs, and responsive navigation.

Overview

Navigation patterns help users move through your site.

Key Concepts

  • Navbar — Top navigation bar
  • Sidebar — Side navigation
  • Breadcrumb — Page hierarchy
  • Tabs — Content switching
  • Responsive — Mobile navigation

Code Examples

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary);
}

.navbar-nav {
  display: flex;
  gap: 2rem;
  list-style: none;
}

.nav-link {
  text-decoration: none;
  color: #333;
  font-weight: 500;
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: width 0.3s ease;
}

.nav-link:hover::after {
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background: #f8f9fa;
  padding: 2rem 0;
  height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-link {
  display: block;
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  color: #333;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background: #e9ecef;
}

.sidebar-link.active {
  border-left-color: var(--primary);
  background: #e7f1ff;
  color: var(--primary);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: '›';
  margin-right: 0.5rem;
  color: #999;
}

.breadcrumb-link {
  text-decoration: none;
  color: var(--primary);
}

.breadcrumb-item.active {
  color: #666;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid #ddd;
  gap: 0;
}

.tab {
  padding: 1rem 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  color: #666;
}

.tab::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.tab.active::after,
.tab:hover::after {
  transform: scaleX(1);
}

.tab.active {
  color: var(--primary);
  font-weight: 600;
}

/* Mobile menu */
.mobile-menu {
  display: none;
}

@media (max-width: 768px) {
  .navbar-nav {
    display: none;
  }
  
  .mobile-menu {
    display: block;
  }
}

Practice

Build a responsive navigation with sidebar and mobile menu.

Advertisement