javascript - jquery change opacity and height on scroll -
i'm trying write little js. navigation has gradient set background. want background change in height , gradient flat color 0.85 opacity (animated) when scroll down amount.
here's js code
$(window).scroll(function(){ if ($(window).scrolltop() >= 600){ $('#navigation').css({height: '92px'}); } else { $('#navigation').css({height: '142px'}); } });
here's css
#navigation { height: 142px; width: 1350px; position: fixed; z-index: 2000; background: -moz-linear-gradient(top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0) 100%); /* ff3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.75)), color-stop(100%,rgba(0,0,0,0))); /* chrome,safari4+ */ background: -webkit-linear-gradient(top, rgba(0,0,0,0.75) 0%,rgba(0,0,0,0) 100%); /* chrome10+,safari5.1+ */ background: -o-linear-gradient(top, rgba(0,0,0,0.75) 0%,rgba(0,0,0,0) 100%); /* opera 11.10+ */ background: -ms-linear-gradient(top, rgba(0,0,0,0.75) 0%,rgba(0,0,0,0) 100%); /* ie10+ */ background: linear-gradient(to bottom, rgba(0,0,0,0.75) 0%,rgba(0,0,0,0) 100%); /* w3c */ filter: progid:dximagetransform.microsoft.gradient( startcolorstr='#bf000000', endcolorstr='#00000000',gradienttype=0 ); /* ie6-9 */
}
hope can me
your code !!
just create 2 separate class , replace $('#navigation').css({height: '92px'});
$('#navigation').addclass("flatcolored");
, $('#navigation').removeclass("flatcolored");
in 'else'.
instead of having #navigation{ ...}
in css, use .gradientcolored{...} .flatcolored{...}
and in html : <div id="navigation" class="gradientcolored">...</div>
override background
properties in 'flatcolored class.
tested on chrome, based on code. works fine !
Comments
Post a Comment