HTML/CSS
Style the Nav bar using flex box:
What is flex box in css?
Flexbox is a powerful CSS tool that makes it easier to design flexible and responsive layouts. By defining a flex container and using various Flexbox properties, you can control the alignment, spacing, and distribution of elements within that container, making your web design more adaptable and efficient.
HTML CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flexbox Navbar</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<nav class="navbar">
<div class="logo">
<a href="#">LOGO</a>
</div>
<ul class="nav-links">
<li><a href="#">Home</a></li>
<li><a href="#">Page</a></li>
<li><a href="#">Catalog</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
<div class="search-box">
<input type="text" placeholder="Search" />
<button type="submit">🔍</button>
</div>
</nav>
</body>
</html>
CSS CODE:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
}
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #2c3e50; /* Dark blue background */
padding: 10px 20px;
}
.logo a {
color: white;
text-decoration: none;
font-size: 24px;
font-weight: bold;
}
.nav-links {
list-style: none;
display: flex;
}
.nav-links li {
margin: 0 15px;
}
.nav-links a {
color: white;
text-decoration: none;
font-size: 18px;
}
.nav-links a:hover {
color: #f39c12;
}
.search-box {
display: flex;
align-items: center;
}
.search-box input[type="text"] {
padding: 5px;
border: none;
border-radius: 3px 0 0 3px;
outline: none;
}
.search-box button {
padding: 5px 10px;
background-color: #ADD8E6;
border: none;
border-radius: 0 3px 3px 0;
cursor: pointer;
color: white;
}
.search-box button:hover {
background-color: #ADD8E6;
}
0 Comments