Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

How do i change the color of my navbar that has a fixed position?

Course Queries Syllabus Queries
Max. 2000 characters
Replies

usr_profile.png
Shalini Jaiswal

User

( 5 months ago )

 

I've been trying to add "background-color" but that just leaves a big empty gap in between the header img and header nav due to the position.Without the position, the header nav wouldn't be where i want it to be (towards the right)
(I can't use any bootstrap or whatever because its not in my syllabus and im just starting out to code)

This is my code:

 

header {
  margin-top: auto;
  height: 79px;
  overflow: hidden;
}

header img {
  float: left;
  position: fixed;
  z-index: 2;
  top: 0;
}

header nav {
  float: right;
  position: fixed;
  z-index: 2;
  top: 0;
  height: 79px;
  left: 542px;
}
<header>
  <a href="index.html"><img src="images/greylogo.png" alt="E R I" /></a>
  <nav>
    <ul>
      <li> <a href=#> Home </a> </li>
      <li> <a href="aboutme.html"> About Me </a> </li>
      <li> <a href="events.html"> Events </a></li>
      <li> <a href="contact.html" target="_blank"> Contact Me </a></li>
    </ul>
  </nav>
</header>

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif