Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

why is my nav bar off screen to the left? (extreme biginner)

just like the title says, why is it doing this?: [why is adding images weird here: pic of problem

here is the code for it(i got it off of this w3 schools tutorial)

/* The navigation bar */

.navbar {
  overflow: hidden;
  background-color: #333;
  position: fixed;
  /* Set the navbar to fixed position */
  top: 0;
  /* Position the navbar at the top of the page */
  width: 100%;
  /* Full width */
}


/* Links inside the navbar */

.navbar a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}


/* Change background on mouse-over */

.navbar a:hover {
  background: #ddd;
  color: black;
}

/* Main content */
.main {
  margin-top: 30px; /* Add a top margin to avoid content overlay */
} 

/* Main content */
.main {
  margin-top: 30px; /* Add a top margin to avoid content overlay */
} 
<div class="navbar">
  <a href="#home">Home</a>
  <a href="#news">News</a>
  <a href="#contact">Contact</a>
</div>
<div class="main"></div>

i tried looking but no one i could find had the same issue so i came here ¯_(ツ)_/¯

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

As your text is distanced as well, i presume the body itself has a margin.

You can try to add left: 0; to .navbar:

.navbar { left: 0; /*...*/ }

Or try to remove the body margin:

body { margin: 0; }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading