Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
How to reset display on a div after changing device size

This is my code and it's horizontal on desktop screen and on phone it's vertical and x button(closebtn) is only on phone displayed and closes the menu bar. How do I automatically display it again, after resizing the page to desktop size?

function oty() {
  document.getElementById("tab").style.display = "none";
}
<div class="icon-bar" id="tab">
  <button class="closebtn" onclick="oty()">X</button>
  <button class="tablink">Home</button>
  <button class="tablink">News</button>
  <button class="tablink">Contact</button>
  <button class="tablink">About</button>
    </div>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

RECOMMENDED: Stick to CSS @media

You can easily add media queries that determine a display of any given element based on viewport size, which is the foundation of responsive design anyways. In your case, keeping the markup as-is, the CSS could be something like...

@media screen and (max-width: 1024px) { // Adjust the break-point size as needed
  #tab {
    display: none;
  }
}

Not recommended: listen for resize event and check the viewport size

While I'd strongly advise against using JavaScript for something CSS is built for, it is possible with JavaScript. Try something like following.

  1. Add a resize event listener to window: (e.g. window.addEventListener('resize', handleResize))
  2. Write a function that toggles your tab element's visibility.
  3. Consider adding a throttle handler to prevent over-firing the events.
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda