TOC 在 HTML 标签包裹时不起作用

Another question. I added extra div to the post. Now it looks like this:

<div data-theme-toc="true"> </div>
<div data-theme-profile="manual">
## Chapter 1
## Chapter 2
</div>

But the TOC is not visible in this case. How can it be fixed?

3 个赞

我不知道你的目的,但你可以通过几种方法来定位标题。

  1. 使用带有 data-attributes 的 HTML 标题标签,例如 <h1>Chapter 1</h1>,这样你就可以用 CSS 定位 [data-header-1]

  2. 在某个地方插入一个带有 data-attribute 的空 div,你可以用它来定位后面的元素。例如,在第二个标题后面放置 <div data-next-titles></div> 并添加此 CSS:

    [data-next-titles] ~ .d-toc-post-heading {
        color: pink;
    }
    

    这将实现:

所以,这真的取决于你的目标。
本指南可能会有所帮助:Customize posts' contents with your own styles

4 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.