It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do i modify where Table of Contents anchors to?

When Im clicking the links in table of contents it moves the page so the header it referred to is placed at the top of the screen. For me it needs to be placed X px down from the top. How can i achieve this?

Ive made a tiny illustration to show what it does now and what i want it to do. 

Hjelp.png

2 answers

1 accepted

1 vote
Answer accepted

I managed to fix this by adding some css to h2 tags in these pages. Because we are using the same naming convention it makes it easy to just style the h2 tags in the right pages. 

h1[id*="2019."]{

padding-top: 70px !important; 

margin-top-30px !Important;

}

0 votes

Hello, @Halvard_Meijer !
As I understand, you need to customize where the automatic page scrolling of our Table of Contents macro stops after you click the link.
Is that correct?
If the above is correct, I can tell you that this is not currently possible. The Table of Contents macro relies on IDs from the webpage itself to work. Browsers have a native function to automatically scroll pages depending on the link that directs you there.

The link https://yourinstance.net will lead you to the start of your page. The link https://yourinstance.net#nextelement will land you right at the element with id nextelement.

As you can see in this screenshot:

Screen Shot 2019-09-05 at 18.36.18.png

What the ToC macro does is create a link that has the #<elementID> at the end. Even though the macro makes use of the <elementID>, the function itself is part of the browser, not Confluence.

Let us hear from you Halvard! Looking forward to your reply.

Thank you for the reply. The reason for this problem is because i made the header bigger and it made the heading hidden beneth the header. 

 

I managed to fix this by adding some css to h2 tags in these pages. Because we are using the same naming convention it makes it easy to just style the h2 tags in the right pages. 

h1[id*="2019."]{

padding-top: 70px !important; 

margin-top-30px !Important;

}

 

((I added this as a response and accepted it as an answer)) 

Hello, Halvard!
Thank you very much for sharing the solution to this. Having some CSS styling can get us a long way!
This shared knowledge will probably help more users of our community.

Let us hear from you.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

How is your team having fun and bonding, remotely, utilizing Confluence?

Thanks everyone for answering last week’s question. The winner of the random drawing from those who commented is: @LarryBrock I’ll contact you separately with your prize details. This wee...

327 views 9 7
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you