I have implemented the following code to resize the logo as I scroll down the page.
$(document).on('scroll', function() {
if ($(document).scrollTop() >= 10) {
$('.logo img').css('width', '50px');
} else {
$('.logo img').css('width', '');
}
});
.nav {
position: fixed;
top: 0;
z-index: 1;
width: 100%;
}
.nav .logo {
position: fixed;
text-align: left;
z-index: 2;
top: 0;
overflow: hidden;
opacity: .5;
}
.container {
padding-top: 120px;
height: 500px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="nav">
<div class="logo">
<a href="index.html"><img src="http://placehold.it/100x100" alt="" /></a>
</div>
</div>
<div class="container">
Lorem ipsum
</div>
I am looking for a way to make the transition smoother when resizing from large to small.
https://jsfiddle.net/sL89qxcx/
Is there any additional code that can be added to achieve a smooth transition?