提问者:小点点

在markdown中添加CSS类到锚链接(雨果)


我在文档中使用锚链接,如下所示:

这很好用,但我想实现以下CSS,以便链接滚动到页面的中间,而不是顶部:

.anchor {
  position: absolute;
  transform: translateY(-50vh);
}

如何将类添加到markdown文档中的锚链接中?


共1个答案

匿名用户

我认为整体markdown支持html标记,例如,您应该能够使用

<p class="anchor">text...</p>

但是不管是哪种方式,如果它真的不起作用,你就没有其他的选择了。例如“fenced Code attributes”:

```{.red .numberLines startFrom="1"}
Here is a paragraph.

And another.
```

这确实是从文档中复制的例子,更多选项确实可以在这里获得:https://lifelongprogrammer.blogspot.com/2019/01/how-to-style-markdown-with-css.html