我的锚链接不会在页面顶部开始 [英] My Anchor link won't start at top of page

查看:127
本文介绍了我的锚链接不会在页面顶部开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定到底是怎么回事。我有两个页脚。一个页脚是一个工具,而我的其他页脚是在页面的底部经常页脚。在我的底部的页脚我的锚标记,链接到我的网页左右,带我到页面,而不是从顶部开始的底部,并在我的侧栏页脚我的锚标记带我到页面的中间!加载时其他锚链接正在我也到页面的中部或随机配件。

I am unsure what is going. I have two footers. One footer is a sidebar, and my other footer is a regular footer on the bottom of the page. My anchor tag in my bottom footer, that links to my about page, takes me to the bottom of the page instead of starting at the top, and my anchor tag in my sidebar footer takes me to the middle of the page! Other Anchor Links are taking me also to the middle or random parts of the pages when loaded.

我没有使用任何特殊的锚。我不认为...

I am not using anything special with the anchor. I don't think...

下面是我的两个注脚主播:

Here is my anchor for both footers:

<a href="/about" class="a-color">
    <small>About</small>
</a>

我的页面加载NG-视图。我的不可以使用 $ anchorScroll

推荐答案

使用此code。它将始终把页面顶部的窗口负载。

Use this code. It will always takes page to top on window load.

 $(window).load(function(){
        if (location.hash) {
          setTimeout(function() {
            window.scrollTo(0, 0);
          }, 1);
        }
 });

这篇关于我的锚链接不会在页面顶部开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆