DEV Community

Cover image for How to create a navbar with HTML and CSS.
 Adeniyi Okunuga
Adeniyi Okunuga

Posted on

How to create a navbar with HTML and CSS.

HTML Codes

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Tech Joint is the most popular programming Teams Group for project development">
    <link href='https://unpkg.com/boxicons@2.1.2/css/boxicons.min.css' rel='stylesheet'>
    <link rel="stylesheet" href="/css/index.css">
    <link rel="icon" href="/img/phone_bg-removebg-preview.png">
    <title>Responsive webpage </title>
</head>
<body>
    <section id="main">
        <header>
            <p class="logo"><i class='bx bx-meteor'></i>Tech Joint </p>
             <nav>
                 <ul class="nav_links">
                     <li class="active"><a href="#main">Home</a></li>
                     <li><a href="#">Projects</a></li>
                     <li><a href="#">About</a></li>
                     <li><a href="#class">Party</a></li>
                 </ul>
             </nav>
             <a href="#" class="cta"><button>Contact</button></a>
         </header>

</body>
</html>
Enter fullscreen mode Exit fullscreen mode

CSS Code

*{
    padding: 0;
    margin: 0;
    font-family: sans-serif;
    box-sizing: border-box;

}
#main {
    height:100vh;

    --webkit-transition: background 6s;
    background-image: url(/img/background-image.png);
    transition-delay: 2s;
    transition-duration: 3s;
 background-size: cover;
}
body {
    background: black;
}


li, a, button {
    font-weight: 500;
    font-size: 16px;
    color: #edf0f1;
    text-decoration: none;

}

header {
    display: flex;
    justify-content:flex-end;
    align-items: center;
    padding: 30px 10%;
    background:rgba(255, 250, 250, 0.164);
    position: sticky;
}
.logo {
    cursor: pointer;
    margin-right: auto;
    font-weight: bolder;

    font-size: 3vh;
    font-family: Arial, Helvetica, sans-serif;
    background: linear-gradient(to right, #f32170,
            #ff6b08, #cf23cf, #eedd44);
    -webkit-text-fill-color: transparent;
    -webkit-background-clip: text;
}

.nav_links{
    list-style: none;
}
.nav_links li {
    display: inline-block;
    padding: 0px 20px;

}
.nav_links li a {
    transition:  all 0.3s ease 0s;
    font-weight: bold;
}

.nav_links li a:hover{
  color:white;
  background:#015958;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition:  all 0.3s ease 0s;
  font-weight: bold;
  padding: 9px 25px;
}
.nav_links li .active{
    color:black;
}
button {
    margin-left: 20px;
    padding: 9px 25px;
    background-color: rgba(0,136, 169, 1);
    border-radius: 50px;
    border: none;
    cursor: pointer;
    transition:  all 0.3s ease 0s;
    font-weight: bold;
}

button:hover {
    background-color: rgba(0, 136,169, 0.8);
}

Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
user_f9d4a343bb profile image
Adeniyi Okunuga

This is my First Time