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

218
Views
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
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!