Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

140
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda