Jump to content

Got anchor links but they wont go to the right place

Recommended Posts

Thanks to some of the other threads on anchor links, I got mine up and running for the most part. The problem is, they're overshooting their target by a good margin on every one. Can someone tell me what I'm missing? This is the code block I have on the page

 

Heres the page : www.thetenmg.com/event

 

Also, how do i make it so the menu can be collapsed to the side if they dont want to use it?
 

This is the code block on the page to get the links visible on the right

<ul class="tp-float-buttons">
        <li><a href="#WHAT">WHAT</a></li>
        <li><a href="#WHO">WHO</a></li>
        <li><a href="#WHEN">WHEN</a></li>
  <li><a href="#WHERE">WHERE</a></li>
  <li><a href="#SPONSOR">SPONSOR</a></li>
  <li><a href="#GUEST">GUEST LIST</a></li>
</ul>
<style>
ul.tp-float-buttons {
    position: fixed;
    top: 15%;
    right: 3px;
    z-index: 999;
    list-style: none;
    padding-left: 0;
    margin: 0;
}
ul.tp-float-buttons a {
    color: white;
    background-color: black;
    padding: 3px;
    margin-bottom: 2px !important;
    display: inline-block;
    min-width: 125px;
    text-align: center;
  font-size: smaller;
  top: 125px;
  position: relative;
 
}
</style>

 

 

And this is the CSS code i had pertaining to it:

html {
  scroll-behavior: smooth;
  scroll-margin: 300px;
}
.anchor {
    display: block;
    position: relative;
    top: -150px;
    visibility: hidden;
  #WHAT {top: -250px;}
}

 

 

and finally this is the code block i put in the very top of each section for the anchor links to refer to:

<div ID="GUEST"></div> 

and

<div ID="WHEN"></div> 

and

<div ID="WHO"></div> 


etc etc

 

Edited by LeauxFi
clarification
Link to comment
  • Replies 1
  • Views 592
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

3 hours ago, LeauxFi said:

Thanks to some of the other threads on anchor links, I got mine up and running for the most part. The problem is, they're overshooting their target by a good margin on every one. Can someone tell me what I'm missing? This is the code block I have on the page

 

Heres the page : www.thetenmg.com/event

 

Also, how do i make it so the menu can be collapsed to the side if they dont want to use it?
 

<ul class="tp-float-buttons">
        <li><a href="#WHAT">WHAT</a></li>
        <li><a href="#WHO">WHO</a></li>
        <li><a href="#WHEN">WHEN</a></li>
  <li><a href="#WHERE">WHERE</a></li>
  <li><a href="#SPONSOR">SPONSOR</a></li>
  <li><a href="#GUEST">GUEST LIST</a></li>
</ul>
<style>
ul.tp-float-buttons {
    position: fixed;
    top: 15%;
    right: 3px;
    z-index: 999;
    list-style: none;
    padding-left: 0;
    margin: 0;
}
ul.tp-float-buttons a {
    color: white;
    background-color: black;
    padding: 3px;
    margin-bottom: 2px !important;
    display: inline-block;
    min-width: 125px;
    text-align: center;
  font-size: smaller;
  top: 125px;
  position: relative;
 
}
</style>

 

 

And this is the CSS code i had pertaining to it:

html {
  scroll-behavior: smooth;
  scroll-margin: 300px;
}
.anchor {
    display: block;
    position: relative;
    top: -150px;
    visibility: hidden;
  #WHAT {top: -250px;}
}

 

I think the reason is the header get over the anchor link so you target is hidden after header. We need to add some addition space for anchor link. 

Currently I find that:

the code block for id #what have 2 elements: div and a element. We should remove the a element, keep only the div and add class on it

image.thumb.png.1d2900d1296055fe055f4ba9558c55ad.png

The other code block is missing the class anchor

image.thumb.png.9cab329f0a8465ac16f2337a1a34d10d.png

Kindly change the code block, the code should go well

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

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.