繁体   English   中英

如何将页码添加到指向锚点的链接?

[英]How do I add a page number to a link to an anchor?

我的网页中有几个锚点(即<a name="my-magical-anchor"></a> )散布在页面上。 我的页面上还有几个指向这些锚点的链接(即<a href="#my-magical-anchor">Go to the Magical Anchor</a> )。 因为在打印页面时,我想知道是否可以使用 CSS 或 JavaScript 修改链接的文本,以读取类似Go to the Magical Anchor (page 12)以指示读者应该翻转的页码到打印的文档中。

如果可能,我想不必手动分配分页符,而是让我的内容在页面上流动,然后在打印前更新链接文本。

谢谢。

看看这篇文章,然后转到标题为“交叉引用”的部分: http : //www.alistapart.com/articles/boom

建议使用target-counter ,针对page计数器,使用href属性作为目标链接。

a.magical::after {
    content: "(page" target-counter(attr(href), page) ")"
}

也推荐整篇文章。 向与之相关联的 Nathan Kot 致敬。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM