Web Development

Flexbox: Build a Responsive Navigation Bar with HTML & CSS

Introduction to Flexbox

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.

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>

CSS

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;
   
}

 

 

 

admin

Share
Published by
admin

Recent Posts

Creating Stunning Image Gallery Using CSS Grid

Introduction to CSS Grid The CSS Grid Layout is a powerful tool for creating responsive…

7 hours ago

Create Professional Login & Registration Form using HTML & CSS

In this tutorils we are going to teach how to make a attractive Login &…

3 weeks ago

Form Repeater using HTML CSS JQuery

In this tutorial we are going to teach Form Repeater using HTML CSS JQuery.step by…

1 month ago

AJAX CRUD Application in Laravel 11

Introduction to AJAX and Laravel 11 AJAX, which stands for Asynchronous JavaScript and XML which…

1 month ago

C#.net Banking Project: Accurate FD Rate Calculation Tutorial

Introduction to FD Rate Calculation In any banking project, accurately calculating Fixed Deposit (FD) rates…

1 month ago

Creating Calculator in WPF with C# – Step-by-Step Tutorial

In this tutorials will teach how to make a calculator using wpf C# application step…

1 month ago