2014-02-17 60 views
0

标题意味着它的含义。当我设置一个链接跳转到某个div它不起作用。例如,当我说<a href="#Section1>Section 1</a>并单击它时,它应该跳转到名称为'Section1'的锚标记,但没有任何反应。HTML Anchor跳转不起作用

<main id="Main"> 
    <div class="Container"> 
     <div class="Section-Links Left Box-Sizing"> 
      <div class="Links"> 
       <a href="#test">Test Post</a> 
       <a href="#test2">Test Post</a> 
       <a href="#test3">Test Post</a> 
       <a href="#test4">Test Post</a> 
       <a href="#test5">Test Post</a> 
       <a href="#test6">Test Post</a> 
       <a href="#test7">Test Post</a> 
       <a href="#test8">Test Post</a> 
       <a href="#test9">Test Post</a> 
       <a href="#test10">Test Post</a> 
      </div> 
     </div> 
     <div class="Sections Left Box-Sizing"> 
      <div class="Section"> 
       <a name="Test"></a> 
       <span class="Section-Title">Test Section</span> 
       <p class="Section-Text">Some Random Words Here.</p> 
      </div> 

      <div class="Section"> 
       <a name="Test2"></a> 
       <span class="Section-Title">Test Section</span> 
       <p class="Section-Text">Some Random Words Here.</p> 
      </div> 

      <div class="Section"> 
       <a name="Test3"></a> 
       <span class="Section-Title">Test Section</span> 
       <p class="Section-Text">Some Random Words Here.</p> 
      </div> 

      <div class="Section"> 
       <a name="Test4"></a> 
       <span class="Section-Title">Test Section</span> 
       <p class="Section-Text">Some Random Words Here.</p> 
      </div> 

      <div class="Section"> 
       <a name="Test5"></a> 
       <span class="Section-Title">Test Section</span> 
       <p class="Section-Text">Some Random Words Here.</p> 
      </div> 

      <div class="Section"> 
       <a name="Test6"></a> 
       <span class="Section-Title">Test Section</span> 
       <p class="Section-Text">Some Random Words Here.</p> 
      </div> 

      <div class="Section"> 
       <a name="Test7"></a> 
       <span class="Section-Title">Test Section</span> 
       <p class="Section-Text">Some Random Words Here.</p> 
      </div> 

      <div class="Section"> 
       <a name="Test8"></a> 
       <span class="Section-Title">Test Section</span> 
       <p class="Section-Text">Some Random Words Here.</p> 
      </div> 

      <div class="Section"> 
       <a name="Test9"></a> 
       <span class="Section-Title">Test Section</span> 
       <p class="Section-Text">Some Random Words Here.</p> 
      </div> 

      <div class="Section"> 
       <a name="Test10"></a> 
       <span class="Section-Title">Test Section</span> 
       <p class="Section-Text">Some Random Words Here.</p> 
      </div> 
     </div> 
     <div class="Clear"></div> 
    </div> 

    <p class="Footer-Masthead">Created By Moussa Harajli.</p> 
</main> 

如果你想测试这个去这里。 http://67.184.73.19/Projects/Assassins/rules.php

+0

哈啊,我们走吧,我没有意识到这是区分大小写的。 –

回答

2

锚链接不指向name秒,但到id小号

因此改变,例如:

<a name="Test7"></a> 

到:

<a id="Test7"></a> 

,你不应该改变资本id属性中的id和链接。

+1

它曾经...并仍然 – Musa

+0

这工作太谢谢。 –

2

尝试设置中的id div标签:

<div id="test" class="Section">...</div> 

这应该工作:

<a href="#test">Test Post</a> 
+0

感谢您的帮助 –

1

您的问题背后的原因是,你在你的链接有不同的ID,因为test2不与Test2相同。

虽然......从我的经验<a>元素基本上是多余的,因为在所有现代浏览器了以下工作:

<main id="Main"> 
    <div class="Container"> 
     <div class="Section-Links Left Box-Sizing"> 
      <div class="Links"> 
       <a href="#test">Test Post</a> 
       <a href="#test2">Test Post</a> 
      </div> 
     </div> 
     <div class="Sections Left Box-Sizing"> 
      <div id="test" class="Section"> 
       <span class="Section-Title">Test Section</span> 
       <p class="Section-Text">Some Random Words Here.</p> 
      </div> 

      <div id="test2" class="Section"> 
       <span class="Section-Title">Test Section</span> 
       <p class="Section-Text">Some Random Words Here.</p> 
      </div>