Animated logo header shrink on scroll
HTML
<div class="header_nav"><img src="http://placehold.it/90x90" /></div>
CSS
body {
height:1000px;
width:100%;
background-color:#F0F0F0;
}
.header_nav {
width:100%;
height:100px;
background-color:#666;
position:fixed;
top:0;
left:0;
}
.header_nav img {
max-height: 100%;
max-width: 100%;
}
JavaScript
$(function(){
$('.header_nav').data('size','big');
});
$(window).scroll(function(){
if($(document).scrollTop() > 0)
{
if($('.header_nav').data('size') == 'big')
{
$('.header_nav').data('size','small');
$('.header_nav').stop().animate({
height:'40px'
},600);
}
}
else
{
if($('.header_nav').data('size') == 'small')
{
$('.header_nav').data('size','big');
$('.header_nav').stop().animate({
height:'100px'
},600);
}
}
});