Hi,
I followed the official tutorial to add a Table of Contents to my articles.
It works okay with stand-alone images that are larger than the main content.
Unfortunately, it gets completely hidden by gallery-type images. Is there a way to correct this?
It’s possible to adjust the CSS (like the z-index) so that the TOC is above other content. But it’ll be difficult to offer any code without a live link. Are you able to share a link to your site? I’m also curious because those images look cool!
Adjusting the CSS with z-index solved the issue of the galleries hiding the ToC on scroll:
.gh-toc {
position: sticky; /* On larger screens, TOC will stay in the same spot on the page */
top: 4vmin;
z-index: 1;
}
Now I’m wondering if there’s a way to push it more to the left so that there’s no overlap at all between wide images and the ToC. I’m assuming doing this could create some responsiveness issues?
.gh-content {
position: relative;
}
.gh-toc > .toc-list {
position: relative;
}
.toc-list {
overflow: hidden;
list-style: none;
}
@media (min-width: 1300px) {
.gh-sidebar {
position: absolute;
top: 0;
bottom: 0;
margin-top: 4vmin;
grid-column: wide-start / main-start; /* Place the TOC to the left of the content */
}
.gh-toc {
position: sticky; /* On larger screens, TOC will stay in the same spot on the page */
top: 4vmin;
}
}
.gh-toc .is-active-link::before {
background-color: var(--ghost-accent-color); /* Defines TOC accent color based on Accent color set in Ghost Admin */
}
@media (min-width: 1300px) {
.gh-sidebar {
position: absolute;
top: 0;
bottom: 0;
margin-top: 4vmin;
grid-column: main-end / full-end; /* Place the TOC to the right of the content */
padding-left: 20px;
}
.gh-toc {
position: sticky; /* On larger screens, TOC will stay in the same spot on the page */
top: 4vmin;
}
}