Jump to content

Anchor Links Not Working w/Sticky Navigation

Recommended Posts

Site URL: https://berkshireic-cms.squarespace.com

I'm trying to add anchor links to my site, but am running into issues with the link landing below the corresponding anchor due to sticky navigation. I'm in Brine, 7.0 and, while I know this particular feature is possible via other methods in 7.1, that is not a possibility here.

Can anyone help with this? Thank you!

You can see an example on this page: https://berkshireic-cms.squarespace.com/clients-services-fees 

password: BIC2021

 

Pinned sticky header using Tuanphan's code from a previous post:

.Header.Header--top {
    position: sticky;
    position: -webkit-sticky;
    top: 0px;
    z-index: 1000;
    width: 100%; }

 

Tried this solution offered in previous post by a Wordpress user. Some folks had success with this, but it does not work for me: 

:target:before {
content:"";
display:block;
height:120px; /* fixed header height*/
margin:-120px 0 0; /* negative fixed header height */ }

Edited by Guest
Link to comment
  • Replies 2
  • Views 922
  • Created
  • Last Reply

Top Posters In This Topic

  • 7 months later...

I was having a similar page-positioning problem on a page with a fixed header and the ":target:before..." solution wasn't working for me either.  (I'm using the Bedford template in Squarespace 7.0)

What did end up working was to specify a class in the target <p> element and then to use CSS to define the class for that particular class.

eg. in a code block on the page add a class name to the <p> element::

<p id="reference1" class="linktarget">Reference 1</p>

and in css define the properties of the "linktarget" class:

.linktarget:before {
  content:"";
  display:block;
  height:120px; /* the height of the fixed header*/
  margin:-120px 0 0; /* the negative of the fixed header height */
}

This solution is based on the "Fixed Header Solution" described here: https://www.minddevelopmentanddesign.com/blog/link-an-anchor-tag-target-location-different-page-expanded-content-fixed-header/

I hope this information is helpful to someone.

 

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.