I read some articles but couldn’t understand them clearly.
There are some things I want my navigation bar to have,
- The background color of the navigation bar shouldn’t have a gap above and on the sides
- I want the elements to be in center but with a some gap between each other.
#nav_bar {
background-color: aliceblue;
padding: 14px 16px;
width: 100%;
}
<!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">
<link rel="stylesheet" href="main.css">
<title>Product Landing Page</title>
</head>
<body>
<nav id="nav_bar" class="nav_class">
<a href="#welcome">Home</a>
<a href="#product-info">Products</a>
<a href="#product-pricing">Pricings</a>
<a href="#about">About</a>
<a href="#contact">Contact Us</a>
</nav>
<section class="welcome">
<h1>Hello</h1>
</section>
</body>
</html>
What are different ways to make a good navigation bar?
I have tried to read various articles from many websitA
2
Answers
}
i think this work
The extra space is from body element’s default margins, you can reset it to 0:
For the navigation, you can use flex to center it as well as giving some space between each item:
Here is an example with the above tweaks: