Make Navbar change style depending on section

Looking for a way to create the same navbar as Dropbox landing page, where it switches colors depending on the section.

www.dropbox.com (open in incognito if you don’t want to log out of your dropbox).

Imgur