- This topic has 9 replies, 5 voices, and was last updated 3 years, 9 months ago by
Ying.
-
AuthorPosts
-
September 25, 2020 at 2:00 pm #1459174
Andrei
Hello guys,
Saw a similar topic about this but no actual solution.
I’ve created a TOC using the “easy table of contents” plugin.Placed this TOC as a widget in the right sidebar of blog posts.
The end goal is to have the TOC on the sidebar, moving along as I scroll down, and also highlighting the corresponding header / section.Please share any CSS code that would enable what I need and also where to place it 🙂
Cheers
September 25, 2020 at 2:02 pm #1459175Leo
StaffCustomer SupportHi there,
Try this CSS:
.single #right-sidebar { position: sticky; top: 0; }Adding CSS: https://docs.generatepress.com/article/adding-css/
September 25, 2020 at 2:15 pm #1459185Andrei
Hi Leo,
Thanks for such a prompt and awesome response. Works like a charm!
There is however one thing.. on mobile the TOC is shown after the post contents.
Is there any way I can show the TOC before the first H2 (only for mobile)?
September 25, 2020 at 8:49 pm #1459333Leo
StaffCustomer SupportTry this CSS:
@media (max-width: 768px) { .site-content { display: flex; flex-direction: reverse-column; } }September 26, 2020 at 1:56 am #1459561Andrei
Hi Leo, tried the code but then the sidebar with TOC is also visible on mobile and the content width gets broken.
So I removed your code, now the TOC is at the end of the content on mobile. (it’s oke for now)
But ran into something else now, the layout’s width on single post only seems to be broken, as the header and the footer are not full width anymore.
I’m using the “READ” site template from the library.
Attached this image for the mobile view. I hope you can help with a fix here 🙂
https://prnt.sc/uo6w7ySeptember 26, 2020 at 7:58 am #1460008David
StaffCustomer SupportHi there,
the overflow is being caused by the Pros / Cons tables.
Add this CSS to fix the problem:.cg-pc-row > * { box-sizing: border-box; }September 26, 2020 at 9:04 am #1460110Andrei
Hi David,
There was indeed something with my pros & cons and your code fixed that!
Many many thanks!!Have a nice weekend!
September 26, 2020 at 2:06 pm #1460311David
StaffCustomer SupportYou’re welcome
June 23, 2022 at 1:33 pm #2262695kenan
Hi there,
I added the css mentioned above to make the easy table of contents sticky in the right sidebar. But it doesn’t seem to work..single #right-sidebar {
position: sticky;
top: 0;
}Here’s the post, https://potentialparadigms.com/blog/life/untethered-nomadic-lust
Thank you
June 23, 2022 at 3:13 pm #2262731Ying
StaffCustomer SupportTry this instead:
.single #right-sidebar .inside-right-sidebar { position: sticky; top: 0; } -
AuthorPosts
- You must be logged in to reply to this topic.