HTMLify

Best Navigation Bar
Views: 37 | Author: djdj
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Responsive Sidebar</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: Arial, sans-serif;
        }

        body {
            display: flex;
        }

        .sidebar {
            width: 250px;
            background: #18191A;
            color: white;
            height: 100vh;
            padding: 20px;
            position: fixed;
            transition: width 0.3s;
        }

        .sidebar.close {
            width: 70px;
        }

        .sidebar .logo {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .sidebar.close .logo h2 {
            display: none;   /* Logo text hidden when sidebar is closed */
        }

        .sidebar .logo i {
            font-size: 24px;
            cursor: pointer;
        }

        .menu {
            margin: 20px -10px;
        }

        .menu li {
            list-style: none;
            padding: 15px;
            display: flex;
            align-items: center;
            cursor: pointer;
        }

        .menu li:hover {
            background: #242526;
            border-radius: 10px;
        }

        .menu i {
            font-size: 20px;
            margin-right: 10px;
        }

        .menu span {
            transition: opacity 0.3s;
        }

        .sidebar.close .menu span {
            opacity: 0;
            pointer-events: none;
        }

        .content {
            margin-left: 250px;
            padding: 20px;
            transition: margin-left 0.3s;
            width: 100%;
        }

        .sidebar.close + .content {
            margin-left: 70px;
        }
.fa-bars:before, .fa-navicon:before {
    margin-left: 5px;
}
    </style>
</head>
<body>
    <div class="sidebar">
        <div class="logo">
            <h2>SabkaCode</h2>
            <i class="fas fa-bars" id="toggle"></i>
        </div>
        <ul class="menu">
            <li><i class="fas fa-search"></i> <span>Search</span></li>
            <li><i class="fas fa-home"></i> <span>Dashboard</span></li>
            <li><i class="fas fa-user"></i> <span>User</span></li>
            <li><i class="fas fa-envelope"></i> <span>Messages</span></li>
            <li><i class="fas fa-chart-bar"></i> <span>Analytics</span></li>
            <li><i class="fas fa-folder"></i> <span>File Manager</span></li>
            <li><i class="fas fa-shopping-cart"></i> <span>Order</span></li>
            <li><i class="fas fa-heart"></i> <span>Saved</span></li>
            <li><i class="fas fa-cog"></i> <span>Settings</span></li>
        </ul>
    </div>
    <div class="content">
        <h1>Dashboard</h1>
        <p>Welcome to your dashboard!</p>
    </div>
    <script>
        document.getElementById('toggle').addEventListener('click', function() {
            document.querySelector('.sidebar').classList.toggle('close');
        });
    </script>
</body>
</html>

Comments