简体   繁体   中英

Fixed navigation bar with color

I need my fixed navigation bar to be filled with color when scrolling down. How can I make it transparent at the top, but white when being scrolled?

I'm assuming it can be achieved with Jquery, but I don't have a my experience with it, and the shop is build using shopify which makes it a little complicated when editing the code.

Here's a link to my shop https://h-azeem-london.myshopify.com/

Thanks in advance

Something similar to this with your CSS...

header.main-header {
  position: fixed;
  background-color: white;
}

Then with jQuery...

$(window).on("scroll", function () {
    if ($(this).scrollTop() > 50) {
        $("header").css("background-color","rgba(255, 255, 255, 0.25)");
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM