When it comes to building responsive layouts, Flexbox offers a powerful and flexible way to achieve complex designs with minimal code. In this post, we will guide you step-by-step to create a responsive navigation bar using Flexbox in HTML.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="css/style.css"/>
</head>
<body>
<div class="container">
<div class="logo">
<img src="images/push.png" width="230px" height="50px"/>
</div>
<div class="navlinks">
<a href="#">Projects</a>
<a href="#">Services</a>
<a href="#">About</a>
<a href="#">Contact</a>
</div>
<div class="button">
<button class="nav-button">Login</button>
<button class="nav-button">Register</button>
</div>
</div>
</body>
</html> style.css
body{
margin: 0;
padding: 0;
justify-content: center;
font-family: 'noto Sans';
display: flex;
}
.container{
display: flex;
justify-content: space-between;
width: 100%;
height: 100px;
background-color: rgb(18, 135, 224);
align-items: center;
padding: 0 50px;
gap:30px;
color: white;
}
.navlinks{
display: flex;
gap: 20px;
}
.navlinks a{
text-decoration: none;
color: white;
font-size: 20px;
}
.nav-button{
padding-left: 1rem;
padding-right: 1rem;
padding-bottom: 1rem;
padding-top: 1rem;
border-radius: 2%;
font-size: 1rem;
font-weight: bold;
background-color: rgb(3, 80, 139);
color: white;
}
What Is the Tesla Pi Phone? Imagine if Tesla, the company that makes famous…
Inventory Management POS systems are now an essential part of modern businesses such as bookshops,…
If you're just beginning to learn Java GUI programming creating an Water System Calculator is a fantastic project for…
GitHub is a powerful tool used by teams and developers around the globe. This guide is…
It's like having a super-smart buddy that is always there to help you write stories,…
The UK is known for its rich history, diverse culture, and most of all its…