0

I'm trying to remove those small gaps between my nav-link elements and navbar on the bottom as well as on the right side, but can't seem to figure out. I tried setting min-height: 0 and changing it to display: flex and tweaking the justify-content and align-items properties, but didn't achieve the desired outcome. How else could I make it work?

Here is the screenshot: screenshot of the problem

Here is my code:

header {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
}

#logo-container {
  width: 50%;
  text-align: left;
  background-color: lightblue;
}

#navbar {
  font-size: 1.4em;
  width: 50%;
  text-align: right;
  background-color: orange;
  padding: 10px 0px 10px 0px;
}

.nav-link {
  padding: 10px;
  text-decoration: none;
  background-color: green;
}

.nav-link:hover {
  background-color: gray;
}
<header>
    <div id="logo-container"></div>
    
    <nav id="navbar">
      <a class="nav-link" href="#welcome-section">About</a>
      <a class="nav-link" href="#projects">Projects</a>
      <a class="nav-link" href="#contact">Contact</a>
    </nav>
</header>
Konstantink1
  • 575
  • 1
  • 8
  • 26

2 Answers2

2

Replace this css

#navbar {
font-size: 1.4em;
width: 50%;
text-align: right;
background-color: orange;
/* padding: 10px 0px 10px 0px; */
display: flex;
justify-content: flex-end;

}

Mehul Davara
  • 321
  • 2
  • 4
1

Using flex with justify-content: flex-end; we can achieve desire result

header {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
}

#logo-container {
  width: 50%;
  text-align: left;
  background-color: lightblue;
}

#navbar {
  font-size: 1.4em;
  width: 50%;
  text-align: right;
  background-color: orange;
  /* padding: 10px 0px 10px 0px; */
  display: flex;
  align-content: end;
  justify-content: flex-end;
}

.nav-link {
  padding: 10px;
  text-decoration: none;
  background-color: green;
}

.nav-link:hover {
  background-color: gray;
}
<header>
    <div id="logo-container"></div>
    
    <nav id="navbar">
      <a class="nav-link" href="#welcome-section">About</a>
      <a class="nav-link" href="#projects">Projects</a>
      <a class="nav-link" href="#contact">Contact</a>
    </nav>
</header>
Awais
  • 4,752
  • 4
  • 17
  • 40