-1

I am looking at websites for inspiration for my new start ups homepage. I saw https://www.pactcoffee.com/ and their home page features a full background image for the header and the nav bar is transparent then it becomes a solid color nav bar as you scroll down. I have only been able to set up the CSS for the site but I don't understand what to do to have the change in nav bar color.

2 Answers2

1

You can do something like this...

http://jsfiddle.net/ojcqbLr2/

Check the Fiddle to see the rest of the code... like the CSS.

This JS will do this.

$(document).scroll(function () {
var y = $(this).scrollTop();
if (y > 100) {
    $('.topMenu').fadeIn();
} else {
    $('.topMenu').fadeOut();
} });

By the way, I found this info by search. Show div on scrollDown after 800px

I just made edits to the code so it was at the top and not bottom.

Best of luck.

Community
  • 1
  • 1
newJavaCoder
  • 93
  • 1
  • 8
0

I have found that you can set two divs. One of which will be display set to none.

$(document).scroll(function () {
var headerHeight = $('header').height(),
    s = $('.nav'),
    y = $(this).scrollTop();
if (y > headerHeight) {
    $('.navLong').fadeIn();
    $('.nav').fadeOut();

} else {
    $('.navLong').fadeOut();
    $('.nav').fadeIn();
}});

This allows one div to disappear when one appears and vice versa. A working example is can be found in the DEMO