Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
HTML Hamburger menu pushes img down when activated

My hamburger menu pushes down my hero image when clicked, I have tried to add z-index or positions absolute and relative but it ruins the hamburger menu.

I am a beginner and I have been racking my brain for about 2 hours with this.

This started happening when I edited my max-width to be 1200px instead of 600px

body {
  font-family: Montserrat;
  margin: 0px;
}


/* Style the links inside the navigation bar */

.topnav a {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  font-size: 15px;
  color: black;
  width: 32.8%;
  padding-top: 10px;
}


/* Changes color of links on hover */

.topnav a:hover {
  color: #ffffff;
}


/* Add an active class to highlight the current page */

.topnav a.active {
  color: #ffffff;
}


/* Hide the link that should open and close the topnav on small screens */

.topnav .icon {
  display: none;
  float: right;
}


/* When the screen is less than 600 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */

@media screen and (max-width: 1200px) {
  .topnav a:not(:first-child) {
    display: none;
  }
  .topnav a.icon {
    float: right;
    display: block;
    color: white;
  }
}


/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens (display the links vertically instead of horizontally) */

@media screen and (max-width: 1200px) {
  .topnav.responsive {
    position: relative
  }
  .topnav.responsive a.icon {
    position: absolute;
    padding-left: 82.5%;
    top: 0;
  }
  .topnav.responsive a {
    float: none;
    display: block;
    text-align: left;
    padding-top: 10px;
    padding-left: 7.5%;
  }
}
<!-- Nav Bar and background -->
<div class="hero">
  <div class="topnav" id="myTopnav">
    <a href="#home" class="active">About Me</a>
    <a href="#portfolio">Portfolio</a>
    <a href="#about">Contact</a>
    <a href="javascript:void(0);" class="icon" onclick="myFunction()">
      <i class="fa fa-bars"></i>
    </a>
  </div>
  &nbsp;
  <img src="IMG_8302.png" alt="Avatar">
  <div class="hero-text">
    <h1>Hey! I'm Zoe</h1>

    <p>I'm a Junior Web Developer</p>
    <p>Feel free to have a look around my website</p>
  </div>

</div>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!