问题描述
有没有办法设置定位点customley,在实际的HTML标记之外的位置?
Is there a way to set anchor points customley, in positions outside of where the actual HTML mark up is?
我使用这个简单的视差滚动脚本' smoothscroll.js
'at' http://www.kryogenix.org/code/browser/smoothscroll/smoothscroll.js '
I'm using this simple parallax scrolling script called 'smoothscroll.js
' at 'http://www.kryogenix.org/code/browser/smoothscroll/smoothscroll.js'
它通过链接到锚点工作。 但是,我需要将它们放置在标记所在的位置之外。 上方大约200像素。
It works by making links to anchor points. HOWEVER, I need to position them outside of where the markup lays. About 200px above.
我已经尝试使用类和内联的外部CSS。
I've tried external CSS with a class and inline.
EG:
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; }
有任何建议吗?
这个问题是这个问题的派生,锚点
This question is a derivation of this one, Anchor point positionings (2 - Q points, for the help!)
推荐答案
由于 a
不是块元素, margin-top
将无法正常工作。
Since a
is not a block element, margin-top
will not work as expected.
一些修改的CSS:
.anchor {
display: block;
position: relative; /* relative to the parent container, needed for top/left positioning*/
top: -200px;
}
这篇关于设置自定义锚点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!