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

226
Vistas
How to add a transition to logo shrink

I've found a code online which shrinks the header, I've added code to idd to make the logo shrink on scroll.

Now I want to add a transition so the logo resizes with the same effect the header does. I can't seem to get it working.

Javascript

add_action( 'wp_head', function () { ?>
    <script>
       
    // logo laten krimpen 
    window.onscroll = function() {
      growShrinkLogo()
    };
    function growShrinkLogo() {
      var Logo = document.getElementById("Logo")
      if (document.body.scrollTop > 5 || document.documentElement.scrollTop > 5) {
        Logo.style.width = '80px';
      } else {
        Logo.style.width = '150px';
      }
    }
    // resize header 
    jQuery(function($){
      $(window).scroll(function() {
          if ($(document).scrollTop() > 30) {
            $('#section-padding').addClass('reduce-section-padding');
            $('#row-width').addClass('increase-row-width');
        } else {
           $('#section-padding').removeClass('reduce-section-padding');
           $('#section-padding').addClass('slow-transition');
           $('#row-width').removeClass('increase-row-width');
           $('#row-width').addClass('slow-transition');
         
        }
      });
    });
    </script>
    <?php } );

And here is the css:

.reduce-section-padding {
transition: all 0.9s ease-out 0s;
padding-top: 0px !important;
padding-bottom: 0px !important;
margin-top: 0px !important;
}
 
.increase-row-width {
transition: all 0.9s ease-out 0s;
width: 100% !important;
}
 
.slow-transition {
transition: all 0.9s ease-out 0s;
}
 
#main-content {
margin-top: 0vw;
}

I've added the javascript made css class slow-transition to the logo but didn't seem to work.

Hope someone notices something about the code that I didn't.

about 4 years ago · Juan Pablo Isaza
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