我正在使用tocbot在我的網站上構建目錄部分,但是我在滾動時遇到問題,使我在其上方添加的標題堅持到目錄中。https://i.stack.imgur.com/vCm1K.gif 這是我到目前為止所得到的:<div id="desktop-toc" class="tiktoc"> <p class="toc-title">Content Navigation</p> <aside class="toc-container js-sticky"> <div class="toc"></div> </aside></div>CSS /* Start Table of Contents styling */ .toc-container { display: -webkit-box; display: flex; -webkit-box-align: right; align-items: left; } /* Extra small devices (phones, 600px and down) */ @media only screen and (max-width: 600px), only screen and (min-width: 600px) /* Medium devices (landscape tablets, 768px and up) */ @media(min-width: 768px) and (orientation:landscape), only screen and (max-width: 768px) { .tiktoc { display: none; } .toc-container { display: none; } } /* Extra large devices (large laptops and desktops, 1200px and up) */ @media only screen and (min-width: 1200px) { .tiktoc { position: absolute; top: 175px; left: 1150px; bottom: 0; width: 350px; margin-bottom: 0; } .toc { font-size: 16px; line-height: 1.6em; padding: 20px; min-width: 250px; max-width: 300px; background-color: #212121; color: #fff; }我嘗試將標題放在帶有“js-sticky”類的 div 中,但它內聯格式化它們,而不是在 TOC 部分的頂部。
使標題在粘性 div 上具有粘性(tocbot)
撒科打諢
2022-10-13 14:31:37