Jump to content

Marta Template: How to centralise the header (primary navigation) and make it sticky at the top with solid background?

Recommended Posts

Add to Home > Settings > Advanced > Code Injection > Header

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
 $(window).on("scroll", function() {
        //Sticky Header start
   		header = $('header.Header.Header--bottom');
        if ($(window).scrollTop() > 30 ) {
            header.addClass("sticky");
        } else {
            header.removeClass("sticky");
        }
});
</script>
<style>
  .sticky {
  	position: fixed;
    z-index: 999;
    top: 0;
    left: 0;
    width: 100%;
    background: red;
  }
</style>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment

Hi Tuan,

I would like to make 1 section sticky at the top of one page only and with a transparent background (it's a narrow line of text acting as navigation anchor links).

I'm trying to customise the code you gave above, but not having much luck. I put it in Advanced injection code of that page only, right? Is anything required to go in Design/Advanced/CSS to make it transparent?

This is the section ID:

section[data-section-id="5f59e427074004756e44cdd8"]

Thanks so much in advance.

Link to comment
4 hours ago, Sarah-W said:

@tuanphan Sorry, I shouldn't have said transparent, I mean 50% opacity white. Thanks

Can you share site url? We can check easier

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.