Question

When you scroll down on my website, the background of the navbar fades to black.

How can I simultaneously have the color of the links in the navbar animate to the color white (and back to black when going back up)?

This jQuery code is responsible for the navbar:

//jQuery for page scrolling feature - requires jQuery Easing plugin
$(function() {
    $('.page-scroll a').bind('click', function(event) {
        var $anchor = $(this);
        $('html, body').stop().animate({
            scrollTop: $($anchor.attr('href')).offset().top
        }, 1500, 'easeInOutExpo'),
        event.preventDefault();
    });
}); 

I tried to add color: '#fff' almost everywhere, but no luck yet.

Était-ce utile?

La solution

You have to use a plugin to animate text color ... here's one: https://github.com/jquery/jquery-color. jQuery can't do this on it's own.

Autres conseils

Try adding this to your CSS please:

.navbar-custom.top-nav-collapse a { color: #fff; }

Edit: The animation part will be handled by your

a {
    transition: all 0.2s ease-in-out 0s;
}

*in supported browsers ONLY though.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top