Floating TOC in the right column
Asked by Corti Corti:

Hi all,

I have a page with a two columns layout and I put a TOC on the right one. I would like to have the TOC always visible even though when I do scroll down. Is there any nice macro solution for this?

I get some results via CSS, setting a name for the div of the TOC and adding some CSS code like

.fixedPosition {

max-width:370px;

margin: 0 auto;

position: fixed;

top: 200px;

}

any better option?

Many thanks.

J  


Answers:
author: Michelle Rau HP
body: Thanks for this! I got decent results via CSS like this. It's a simple, half-transparent light gray box with a thin blue border that stays visible at the top right of the screen.

```
.toc-btf {    float: right;    position: fixed;    width: 300px;    right: 0px;    top: 170px;    background: rgba(229, 232, 232, 0.5);    border: 1px solid #0096d6;    padding: 5px;}
```

This worked best when I put the TOC with the toc-btf class as the very first thing on the page.

The only annoyance is that other Confluence macros / page parts overlap the TOC in a distracting way. This is minor, but I would rather have the Note's yellow box be under, not over the TOC. If there is an adjustment I can make to CSS please tell me.

I'm a space admin, not a Confluence admin, so my options are limited. I did see the linked solutions above but they're not an option for me.

![overlap.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/17773iB141F3A22A84B4B3/image-size/large?v=v2&px=999 "overlap.PNG")

comments: author: Zden?k ?ediv?
body: Hello,  
I have a solution for your problem. Just move the macro with CSS style to the end of the page so that all the other macros used on the page are above CSS style. See picture. :)  

![1.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/26523iA30D8CE01D9B96DA/image-size/large?v=v2&px=999 "1.PNG")![2.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/26522i24FD88DF5E34C243/image-size/large?v=v2&px=999 "2.PNG")


author: Michelle Rau HP
body: That worked! Thank you!


author: Krishnanand Nayak
body: This solution worked for us.


author: Milo Test
body: @Davin Studer has your solution:

<https://answers.atlassian.com/questions/285311>


author: wld-PKumbhare
body: I got the TOC to float/sticky, thanks to the wonderful suggestions in this thread, but it only works in the preview mode, when I publish the page the TOC loses it's floating/sticky property. Has anyone faced this issue or am I missing something?

comments: author: Mike MacDonald
body: I am having this same issue. Has something changed due to an Atlassian update?


author: Kem McFadden
body: Same issue here. Works in Preview but not in Published mode.


author: Dan Towler
body: Yep - exactly the same issue here - using the Cloud version.

Ie. sticks perfectly in PREVIEW but scrolls once Published.

Has anyone found a fix to this one?


author: hmohapatra
body: I use this css in a two column page layout, for a floating scrollable TOC on the right side.The two column page does not let the content overlap with TOC.

**Screenshot:![Screen Shot 2018-06-08 at 11.20.15 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/24196iC06B8E583461E15E/image-dimensions/567x312?v=v2 "Screen Shot 2018-06-08 at 11.20.15 PM.png")**

**CSS:**

```
.rightFloat {
 position: fixed; 
 height: 600px; 
 overflow: auto;
 top: 100px;
}
```

comments: author: Michelle Rau HP
body: I'll try that out. Thanks much!


author: Zden?k ?ediv?
body: Hi,

What is the macro that you've got the ccs stylesheet on the page?

In Other Macros, there is no such thing.

![css.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/25189i8D0FFE3C9D988006/image-size/large?v=v2&px=999 "css.PNG")

Thank you.


author: hmohapatra
body: Name of the macro is CSS Stylesheet.


author: Zden?k ?ediv?
body: I disagree because there is no such thread on marketplace.atlassian.com. :(

<https://marketplace.atlassian.com/search?query=CSS+StylesSheet>


author: Damien Tan
body: The CSS Stylesheet and div macros in the screenshot above is likely come together with the [Content Formatting for Confluence](https://marketplace.atlassian.com/apps/247/content-formatting-for-confluence) plugin from [Adaptavist](https://marketplace.atlassian.com/vendors/81/adaptavist)


author: Dan Towler
body: Gday team.

I see that this solution, to fix a TOC in place despite scrolling, has been defined using the option:

```
position: fixed;
```

I'm using the Cloud-based Confluence and this control seems to have no effect. I can confirm that all other controls within work. Ie. the TOC is correctly placed on the page, the shading, height and width all effective, but the TOC still scrolls off the page - despite using a FIXED position.

I'd be very grateful to any wiz who can tell me what I'm missing - to make this work.


author: Lam Ton
body: Thanks, it works for me!


author: Xfr Dev
body: Fyi,

I've just created a user style with the css you have provided : <https://userstyles.org/styles/205823/confluence-floating-toc>


author: Sidhartha Kumar Sharma
body: Thanks for the great suggestions in this thread.   

Is there a way to ensure that the floating ToC do not float over the footer section or the comments section? When it sticks beyond the actual content layout, it overlaps with the comments posted on the specific page.


author: Michael Yang - Shinetech Software
body: The floating table of content free plugin has just been released: <https://marketplace.atlassian.com/1221271>

comments: author: Puvaneswary S
body: This is only for Server and data Center not Cloud


author: Anh Nguyen
body: Great. Thanks,


author: ncline-va
body: Would be great to make it available for Cloud :)


author: Michael Yang - Shinetech Software
body: [@Puvaneswary S](/t5/user/viewprofilepage/user-id/4274587) [@ncline-va](/t5/user/viewprofilepage/user-id/4922304) The cloud version is available now!


Tags: css

table-of-contents