javascript - Changing nav-bar color after scrolling? -
how can set navbar no background color?
when scrolling down after div nav-bar gets new background-color (the nav-bar should fixed @ top, use navbar-fixed-top
in bootstrap)
i've tried tutorials didn't succeed.
this website : http://attafothman.olympe.in/
i'm talking black nav-bar on top.
here jsfiddle example. using jquery change background color based on scroll pixel position.
$(document).ready(function(){ var scroll_start = 0; var startchange = $('#startchange'); var offset = startchange.offset(); if (startchange.length){ $(document).scroll(function() { scroll_start = $(this).scrolltop(); if(scroll_start > offset.top) { $(".navbar-default").css('background-color', '#f0f0f0'); } else { $('.navbar-default').css('background-color', 'transparent'); } }); } });
Comments
Post a Comment