image not found

Create Mobile Responsive Navbar using Html and Css


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Navbar CKD</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<nav class="navbar">
<div class="navbar-container">
<a href="#" class="logo">Logo</a>
<input type="checkbox" id="menu-toggle">
<label for="menu-toggle" class="menu-icon">&#9776;</label>
<ul class="nav-menu">
<li class="nav-item"><a href="#" class="nav-link">Home</a></li>
<li class="nav-item"><a href="#" class="nav-link">About Us</a></li>
<li class="nav-item"><a href="#" class="nav-link">Our Service</a></li>
<li class="nav-item"><a href="#" class="nav-link">Contact Us</a></li>
<li class="nav-item auth-buttons">
<a href="#" class="btn register">Register</a>
<a href="#" class="btn login">Login</a>
</li>
</ul>
</div>
</nav>
<h1 class="text-center">Create Mobile Responsive Navbar Simple css Without Using Js</h1>
</body>
</html>

.navbar {
background-color: #333;
color: #fff;
padding: 10px 20px;
position: relative;
}

.navbar-container {
display: flex;
justify-content: space-between;
align-items: center;
}

.logo {
font-size: 24px;
color: #fff;
text-decoration: none;
}

#menu-toggle {
display: none;
}

.menu-icon {
display: none;
font-size: 24px;
cursor: pointer;
}

.nav-menu {
list-style: none;
display: flex;
}

.nav-item {
margin-left: 20px;
}

.nav-link {
color: #fff;
text-decoration: none;
font-size: 18px;
}

.nav-link:hover {
text-decoration: underline;
}

.auth-buttons .btn {
color: #fff;
text-decoration: none;
padding: 10px 20px;
margin-left: 10px;
border: 1px solid #fff;
border-radius: 5px;
transition: background-color 0.3s;
}

.btn.login {
background-color: #ff5d7d; /* Green */
border: none;
}

.btn.register {
background-color: #00a61d; /* Blue */
border: none;
}

.btn:hover {
background-color: #555;
border-color: #555;
}

/* Responsive Mobile Css*/

.text-center{text-align: center;}
@media (max-width: 768px) {
.navbar-container {
flex-direction: column;
align-items: flex-start;
}

.menu-icon {
display: block;
position: absolute;
right: 12px;
}

.nav-menu {
display: none;
flex-direction: column;
width: 100%;
}

.nav-menu.active {
display: flex;
}

.nav-item {
margin: 10px 0;
}

.auth-buttons .btn {
margin: 10px 0;
}
}

#menu-toggle:checked + .menu-icon + .nav-menu {
display: flex;
padding: 0px;
}

Empty


Comments (7 )

Ram
6 Jun 2024

https://www.w3schools.com/css/tryit.asp?filename=trycss_navbar_horizontal_black.

Sneha Adhikari
6 Jun 2024

https://www.w3schools.com/css/tryit.asp?filename=trycss_navbar_horizontal_dividers.

Shyam
22 Jun 2024

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Code karne do</title> <style> /* Basic styling for the navbar */ body { font-family: Arial, sans-serif; } .navbar { background-color: #333; overflow: hidden; } .navbar a { float: left; display: block; color: white; text-align: center; padding: 14px 20px; text-decoration: none; } .navbar a:hover { background-color: #ddd; color: black; } /* Hide the checkbox */ #toggle-nav { display: none; } .logo{display: none;} /* Label styling */ .toggle-label { display: none; padding: 14px 20px; background-color: #333; color: white; cursor: pointer; } .toggle-label:hover { background-color: #fff; color: black; } a.text-log-reg {float: right;} /* Media query for smaller screens */ @media only screen and (max-width: 767px){ .navbar a { display: none; } .logo{display: block;position: absolute;top: 12px;left: 12px;} a.text-log-reg {float: left;} .toggle-label { display: block; text-align: end; } #toggle-nav:checked ~ .navbar a { display: block; float: none; text-align: left; width: 100%; } } </style> </head> <body> <!-- Toggle checkbox --> <input type="checkbox" id="toggle-nav"> <!-- Label for the toggle checkbox --> <img src="https://codekarnedo.com/malinLogo.png" class="logo" alt="text" height="40"> <label for="toggle-nav" class="toggle-label">☰ Menu</label> <!-- Navbar --> <div class="navbar"> <a href="#home">Home</a> <a href="#services">Services</a> <a href="#about">About</a> <a href="#contact">Contact</a> <a href="#login" class="text-log-reg">Login</a> <a href="#register" class="text-log-reg">Register</a> </div> </body> </html>.

Shyam
22 Jun 2024

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Code karne do</title> <style> /* Basic styling for the navbar */ body { font-family: Arial, sans-serif; } .navbar { background-color: #333; overflow: hidden; } .navbar a { float: left; display: block; color: white; text-align: center; padding: 14px 20px; text-decoration: none; } .navbar a:hover { background-color: #ddd; color: black; } /* Hide the checkbox */ #toggle-nav { display: none; } .logo{display: none;} /* Label styling */ .toggle-label { display: none; padding: 14px 20px; background-color: #333; color: white; cursor: pointer; } .toggle-label:hover { background-color: #fff; color: black; } a.text-log-reg {float: right;} /* Media query for smaller screens */ @media only screen and (max-width: 767px){ .navbar a { display: none; } .logo{display: block;position: absolute;top: 12px;left: 12px;} a.text-log-reg {float: left;} .toggle-label { display: block; text-align: end; } #toggle-nav:checked ~ .navbar a { display: block; float: none; text-align: left; width: 100%; } } </style> </head> <body> <!-- Toggle checkbox --> <input type="checkbox" id="toggle-nav"> <!-- Label for the toggle checkbox --> <img src="https://codekarnedo.com/malinLogo.png" class="logo" alt="text" height="40"> <label for="toggle-nav" class="toggle-label">☰ Menu</label> <!-- Navbar --> <div class="navbar"> <a href="#home">Home</a> <a href="#services">Services</a> <a href="#about">About</a> <a href="#contact">Contact</a> <a href="#login" class="text-log-reg">Login</a> <a href="#register" class="text-log-reg">Register</a> </div> </body> </html>.

1
26 Jun 2024

1.

1
24 Jul 2024

1.

1
24 Jul 2024

1.

Leave A Comment

Click for Ad