I'll help you create a responsive header with a desktop sidebar layout and mobile-friendly navigation. Here's the code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Site Title</title>
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Custom CSS -->
<style>
/* Desktop styles */
@media (min-width: 768px) {
body {
background-color: #ADD8E6;
padding: 10px;
min-height: 100vh;
}
.main-container {
background-color: white;
border-radius: 15px;
min-height: calc(100vh - 20px);
display: flex;
overflow: hidden;
}
.sidebar {
width: 250px;
background-color: #f8f9fa;
border-right: 1px solid #dee2e6;
padding: 20px;
border-radius: 15px 0 0 15px;
}
.sidebar .logo {
width: 100%;
height: 80px;
background-color: #dee2e6;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 30px;
color: #6c757d;
}
.sidebar-menu {
list-style: none;
padding: 0;
margin: 0;
}
.sidebar-menu li {
margin-bottom: 10px;
}
.sidebar-menu a {
display: block;
padding: 12px 15px;
color: #333;
text-decoration: none;
border-radius: 8px;
transition: all 0.3s;
}
.sidebar-menu a:hover {
background-color: #e9ecef;
color: #0056b3;
}
.sidebar-menu a.active {
background-color: #0056b3;
color: white;
}
.sidebar-menu i {
margin-right: 10px;
width: 20px;
text-align: center;
}
.content-area {
flex: 1;
padding: 30px;
overflow-y: auto;
}
.mobile-header {
display: none;
}
}
/* Mobile styles */
@media (max-width: 767px) {
body {
background-color: white;
padding: 0;
}
.main-container {
min-height: 100vh;
}
.sidebar {
display: none;
}
.content-area {
padding: 0;
padding-top: 56px; /* Account for fixed navbar */
}
.mobile-header {
display: block;
}
}
</style>
</head>
<body>
<!-- Mobile Header -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top mobile-header">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src="https://via.placeholder.com/150x40" alt="Logo" height="30">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link active" href="#"><i class="fas fa-home"></i> Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><i class="fas fa-chart-bar"></i> Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><i class="fas fa-users"></i> Users</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><i class="fas fa-cog"></i> Settings</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><i class="fas fa-envelope"></i> Messages</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><i class="fas fa-sign-out-alt"></i> Logout</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Main Container -->
<div class="main-container">
<!-- Desktop Sidebar -->
<aside class="sidebar">
<div class="logo">
<img src="https://via.placeholder.com/200x60" alt="Logo" style="max-width: 100%; max-height: 100%;">
</div>
<ul class="sidebar-menu">
<li><a href="#" class="active"><i class="fas fa-home"></i> Home</a></li>
<li><a href="#"><i class="fas fa-chart-bar"></i> Dashboard</a></li>
<li><a href="#"><i class="fas fa-users"></i> Users</a></li>
<li><a href="#"><i class="fas fa-cog"></i> Settings</a></li>
<li><a href="#"><i class="fas fa-envelope"></i> Messages</a></li>
<li><a href="#"><i class="fas fa-sign-out-alt"></i> Logout</a></li>
</ul>
</aside>
<!-- Content Area -->
<main class="content-area">
<!-- Your page content goes here -->
<h1>Welcome to Your Dashboard</h1>
<p>This is where your main content will go.</p>
</main>
</div>
<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- Bootstrap 5 JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<!-- Custom JavaScript -->
<script>
$(document).ready(function() {
// Add active class to current menu item
$('.sidebar-menu a, .navbar-nav a').click(function() {
$('.sidebar-menu a, .navbar-nav a').removeClass('active');
// Get the href of clicked item
var href = $(this).attr('href');
// Set active on both desktop and mobile menus
$('.sidebar-menu a[href="' + href + '"]').addClass('active');
$('.navbar-nav a[href="' + href + '"]').addClass('active');
});
});
</script>
</body>
</html>
This header design features:
Desktop (768px and above):
- Light blue background (
#ADD8E6) for the entire page
- White container with 10px inset on all sides
- Rounded corners (15px border-radius)
- Fixed sidebar on the left with:
- Logo placeholder at the top
- Vertical menu with Font Awesome icons
- Hover effects and active state styling
Mobile (below 768px):
- Standard Bootstrap navbar with hamburger menu
- Fixed to top for easy access
- Contains all the same menu items as desktop
- Clean white background following Bootstrap defaults
The menu items are synchronized between desktop and mobile views using jQuery. You can easily modify the menu items, colors, or spacing to match your specific needs. The content area is ready for your main page content.