有没有办法在实际 HTML 标记之外的位置自定义设置 anchor ?
我正在使用名为“smoothscroll.js
”的简单视差滚动脚本,位于“ http://www.kryogenix.org/code/browser/smoothscroll/smoothscroll.js”。 '
它的工作原理是建立指向 anchor 的链接。 但是,我需要将它们放在标记所在的位置之外。 上方约 200px。
我尝试过使用类和内联的外部 CSS。
EG:
<a name="kids" class="anchor" style="margin-top:-200px;"></a>
<a name="kids" class="anchor" style="margin-top:-200px;"></a>
.anchor { margin-top: -200px; }
有什么建议吗?!
这个问题是这个问题的派生,Anchor point positionings (2-Q分,求助!)
最佳答案
由于 a
不是 block 元素,margin-top
将无法按预期工作。
这是一些修改过的 CSS:
.anchor {
display: block;
position: relative; /* relative to the parent container, needed for top/left positioning*/
top: -200px;
}
关于javascript - 设置自定义 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9380034/