Jump to content

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

Recommended Posts

  • Replies 8
  • Views 586
  • Created
  • Last Reply

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

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


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

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

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:


Thanks so much in advance.

Link to comment


This topic is now archived and is closed to further replies.

  • 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.