简体   繁体   English

固定的导航栏颜色

[英]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. 我以为它可以用Jquery来实现,但是我没有经验,而且商店是使用shopify构建的,这使得编辑代码时有些复杂。

Here's a link to my shop https://h-azeem-london.myshopify.com/ 这是我商店的链接https://h-azeem-london.myshopify.com/

Thanks in advance 提前致谢

Something similar to this with your CSS... CSS与此类似...

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

Then with jQuery... 然后用jQuery ...

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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