锚链接落在错误的位置

JVG*_*JVG 12 html anchor position hyperlink

可能是一个愚蠢的问题,但老实说我无法解决这里出了什么问题.

http://harrisonfjord.com/thinkinc/

我正在建立的一个网站.我想在http://harrisonfjord.com/thinkinc/index.php#sponsors上建立一个锚点链接.我已经在以下代码中设置了锚点:

<a name="sponsors"></a>
    <div class="sponsors">
        <div class="sponsors-left">
            <h2>Sponsors</h2>
                <p>Support the lovely folks who support us! Visit their websites, join their mailing lists and peruse their wares. They are all highly-deserving of your custom, and we're thrilled to have each and everyone one of them on-board!</p>
            </div>
Run Code Online (Sandbox Code Playgroud)

但是,当你点击锚链接时,它会降低到div的一半.我认为在锚链接加载后加载图像可能会出现问题,因此我手动为所有标记添加宽度/高度.我也对标题栏中的cufon文本替换做了同样的事情.

这些都没有帮助,所以现在我转向你.无论出于何种原因,锚也无法在Firefox中运行.我在这里做错了什么想法?

干杯!

msw*_*msw 13

我认为问题是由没有你正在使用的内容的锚点引起的.

此外,似乎name=赞成弃用id=如在某些元件(包括一个片段标识符A),这使得一种意义上ID属性是独特而NAME属性不是这样保证.

我尝试将片段标识符粘贴在实际的可渲染实体中,例如:

<h2 id="sponsors">Sponsors</h2>
Run Code Online (Sandbox Code Playgroud)

并看看它在哪里得到你.顺便说一句,它看起来像一个很好的会议,我希望你得到一个comp入场.


var*_*ard 8

我在Firefox中得到了完全相同的问题并用此解决了它(与sasi答案相同但更通用 - 它检测到url中是否有锚并滚动到它):

$(document).ready(function() {
    if(window.location.hash.length > 0) {
        window.scrollTo(0, $(window.location.hash).offset().top);
    }
});
Run Code Online (Sandbox Code Playgroud)

这似乎是一个众所周知的问题,请参阅https://bugzilla.mozilla.org/show_bug.cgi?id=60307