There are 2 methods to fix this.
Method 1:
Try adding left: 0px;
to the .navbar
selector.
Here is your code:
.navbar {
width: 100%;
background-color: #555;
overflow: hidden;
position: fixed;
top: 0;
padding: 0px;
left: 0px;
scroll-behavior: smooth;
}
.navbar a {
float: left;
text-align: center;
padding: 12px;
color: white;
text-decoration: none;
font-size: 17px;
}
.navbar a:hover {
background-color: #000;
}
.active {
background-color: #4CAF50;
}
@media screen and (max-width: 600px) {
.navbar a {
float: none;
display: block;
}
}
<div class="navbar">
<a class="active" href="#about">About Me</a>
<a href="#skills">Skills</a>
<a href="#schedule">Schedule</a>
<a href="#contact">Contact</a>
</div>
Here is a living demo: https://codepen.io/marchmello/pen/gOarVVo
Method 2:
Add margin: 0;
to the body
selector.
Here is your code:
body {
margin: 0;
}
.navbar {
width: 100%;
background-color: #555;
overflow: hidden;
position: fixed;
top: 0;
padding: 0px;
scroll-behavior: smooth;
}
.navbar a {
float: left;
text-align: center;
padding: 12px;
color: white;
text-decoration: none;
font-size: 17px;
}
.navbar a:hover {
background-color: #000;
}
.active {
background-color: #4CAF50;
}
@media screen and (max-width: 600px) {
.navbar a {
float: none;
display: block;
}
}
<div class="navbar">
<a class="active" href="#about">About Me</a>
<a href="#skills">Skills</a>
<a href="#schedule">Schedule</a>
<a href="#contact">Contact</a>
</div>
Here is a living demo: https://codepen.io/marchmello/pen/KKdMPKJ