【发布时间】:2021-09-04 15:26:01
【问题描述】:
<html><body>
<details open><summary>This is the summary</summary>
<a name="a1"></a>
<p>Here are all the details.</p>
</details>
<p>Imagine more than a page of text here.</p>
<p><a href="#a1">This</a> is a link pointing inside the details.</p>
</body></html>
我正在使用 Firefox 浏览器打开我上面的 HTML 代码。当我单击“此”链接时,Firefox 会正确滚动到详细信息页面。
但是,当我单击标题“这是摘要”左侧的三角形时,详细信息(包括带有锚点的行)被关闭(消失),单击链接 Firefox 不会滚动到锚点更多。
我本来希望 Firefox 至少滚动到隐藏锚点的可见摘要,即使详细信息已关闭,但理想情况下也可以打开详细信息并准确滚动到锚点。
有没有办法(HTML?css?使用哪个浏览器?其他?)可以滚动到 details-summary 块的关闭(折叠)详细信息中的锚点?
我的问题与Scroll to anchor when expanding details/summary? 有关,但如果存在,我更喜欢无 javascript 的解决方案。
要测试您的解决方案,请将“此处的文字不止一页”替换为实际的多页文字。
【问题讨论】:
标签: javascript html css anchor details-tag